Control Your Mac Remotely with Drafts, Hazel, Dropbox & AppleScript

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:

This rule limits the matches to text documents, and moves the text file to the Trash when complete.
Click on the “i” next to “Edit script” to paste the AppleScript linked to earlier.

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. 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.

15 thoughts on “Control Your Mac Remotely with Drafts, Hazel, Dropbox & AppleScript

  1. This ancient article led me to make a similar system in a totally different way. Long story short: set Apache to run as the logged-in user, enable PHP, and use PHP’s exec() function to run shell scripts that contain AppleScript. I have a Mac Mini and the included remote will launch Front Row but I wanted a way to run other apps. So, to launch Hulu desktop, I click a link to mini.local/remote/index.php?function=launchHuluDesktop which in turn runs a shell script with one line: “/usr/bin/osascript -e ‘tell application “/Applications/Hulu” to activate'”

    1. I’m no programmer, but I think a lot of what Hazel does behind the scenes is set up these kinds of actions in a user-friendly package to let us mere mortals do powerful things like what you mentioned.

      I used to have a setup where I would do similar things via Apple Mail rules, as you can use those to launch an AppleScript as well. What I like about the Drafts approach is that it’s much faster to accomplish on the iPhone end of things due to the speed of Drafts.

  2. This sounds like it is working well for you, but I’ll offer that Keyboard Maestro’s native web server/iOS app combination would provide as much (or more) functionality, with fewer moving parts. Not to mention that it doesn’t depend on 3-4 unrelated software vendors. It also provides the additional benefit of being able to trigger any of the defined commands via other means, be it locally with a hotkey or any other supported KM trigger.

    I completely understand the fetish with Dropbox and static files these days (see: markdown, SecondCrack, Pelican, etc…), but in this case it feels a bit Rube Goldberg inspired.

    Once you go Keyboard Maestro, you never go back.

    1. Jordan,

      I’m sure Keyboard Maestro is great, but seeing as how I already have all these apps already, this is “free”.

      I do recall giving KM a go years ago, but it had a steep learning curve from what I recall an seemed overkill for my needs (at least back then).

      One key aspect of this is that I already have Drafts in my Dock, it launches super fast and it’s inexpensive. Curious if I can use the KM iPhone app with the same speed and ease.

      I’ll have to give it another look, thanks!

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s