I wanted to set up a way to to toggle my Mac’s system volume setting from the iPhone. But this technique could be used for any AppleScript you’d like to trigger remotely from your iPhone. Here’s how I did it.
You’ll need the following apps:
• Drafts (iOS)
• Hazel (OS X)
• Dropbox (OS X)
You’ll first need to link Drafts with your Dropbox account (get a free Dropbox account here).
Next, set up a rule in Hazel that watches for text files. Hazel can also parse the contents of files (which I was not aware of until I set up this workflow), so we can use this to trigger Hazel to run the AppleScript. I set my rule to look for the text “#v” (without the quotes) in a text file. I’d suggest using some set of characters that wouldn’t be typically found in a text file so you don’t get random triggers for the Hazel rule. The action performed is to run an embedded AppleScript. Use this AppleScript to toggle your Mac’s system volume level to either 0% or 50% (or any AppleScript you prefer). You can see my Hazel rule below:
I’ve uploaded this Hazel rule if you’d like to use as-is. Just download the file to your Mac, and double-click the file to install in Hazel. You’ll need to manually add your own Drafts folder (found in your own Dropbox folder) to Hazel, and then associate this rule to the Drafts folder.
Drafts.app for the iPhone allows me to quickly save a text file to Dropbox. All I need to do is create a new note (or use an existing one) with the text #v, save to Dropbox, and since Hazel is monitoring this folder it will match the conditions, run the AppleScript and toggle the volume.
As I mentioned, this can be used to trigger any AppleScript, Automator workflow, a shell script or anything else that Hazel supports. You could easily launch applications, mount or unmount hard drives, and pretty much an endless list of things that AppleScript or Automator can perform.
2012-07-23: I love this idea from Ben Brooks to set up Launch Center Pro triggers to send commands to Drafts, making this even better for common tasks if you also have Launch Center Pro.
2013-01-05: Got a mention from Drafts developer Greg Pierce in his interview over at Macstories.
2013-04-09: A method to toggle 10.8 Notifications on/off instead of toggling the system volume.