Talking to Siri: Remote-Controlling Your Mac By Voice | TUAW


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.

on run
— just here to get things started…
end run

on idle
tell application “Notes”
if exists note “What apps are running?” then
delete note “What apps are running?”
tell application “Finder”
set myRunningApps to name of every process whose visible is true
tell application “Notes”
if exists note “Running Apps:” then
delete note “Running Apps:”
end if
set noteTitle to “Running Apps:”
set AppleScript’s text item delimiters to “, ”
set appsList to myRunningApps as text
make new note at folder “Notes” with properties {name:noteTitle, body:appsList}
end tell
end tell
else if exists note “Shut down” then
delete note “Shut down”
tell application “Finder” to quit
else if exists note “Go to sleep” then
delete note “Go to sleep”
tell application “Finder” to sleep
else if exists note “Restart my mac” then
delete note “Restart my mac”
tell application “Finder” to restart
end if
end tell
return 1
end idle

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…

Courtesy of:
Talking to Siri: Remote-Controlling Your Mac By Voice | TUAW


Leave a Reply

Please log in using one of these methods to post your comment: 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