Latest in Applescript

Image credit:

Talking to Siri: Remote-controlling your Mac by voice with Siri Listener


In this episode of "Stupid Siri Tricks," I make my iOS devices control a remote Mac. How remote? Well, it should work anywhere on the planet (or off, if you happen to be on the International Space Station) with Wi-Fi or a cellular data connection. If you can take a note with Siri, you can make your Mac do your bidding from wherever you may be.

I was inspired to do this after watching a video by Niles Mitchell in which he uses a 512K Mac with the original Mac Speak application to issue a command to Siri, which then set a chain of events into motion resulting in some files being moved from that ancient Mac to Dropbox.

It occurred to me that he was using the Notes application and iCloud to accomplish all of this. Essentially, you tell Siri to "Write a note", after which you dictate a note and it is synced to all of your devices through iCloud. The lightbulb went on, so I wrote a quick little application in AppleScript to wait for certain notes to appear and then perform actions on the Mac.

One of the more useful things I could think of was the ability to shut down my Mac or at least put it to sleep if I forgot to do so before going on a trip, so I set up my application to look for "Shut down" or "Go to sleep" notes to perform either of those actions. Perhaps I want to do a remote restart? All I have to do is tell Siri "Restart my mac" and it happens. I also built in the ability to see what apps are currently running on my Mac and return them to my iPhone or iPad in another note. The possibilities are endless...

To use this little "Siri Listener" app, just copy the code below and paste it into a blank AppleScript Editor page. Save the code in case you want to add your own customizations at some point, and then Export as an Application, making sure that you check the boxes for "Stay open after run handler" and "Run-only". To make sure your Siri Listener is always available for your commands, make sure you set it to run at startup.

Make sure that you know how to use Siri to take notes. Just press the home button on your favorite iOS device, wait for the Siri prompt, and then say "Write a note". Siri responds with some sort of question about what you want the note to say, after which you can speak the appropriate command.

Note that I wasn't thinking clearly when I wrote my initial script -- I actually have to say "What apps are running question mark" to get the note in the proper format for Siri Listener to act upon. I'm probably going to change it to something more generic like "List my mac apps" to avoid the punctuation.

I was really wishing that the Photo Booth app was scriptable, as it would be possible to have the Mac's camera take a picture and then attach it to a Note for you to view. I can also see that the Siri Listener idea could be the perfect tool for playing pranks on unsuspecting co-workers, but of course you wouldn't do that...

Have fun! And if you come up with some fun and/or productive uses for the Siri Listener, let me know in the comments. Want more Siri tips? There's a book for that.

From around the web

ear iconeye icontext filevr