Controlling iTunes using Android Wear
I happen to be surrounded by a lot of gadgets lately. One of them is a pretty Moto 360, one of the early Android Wear watches:
and another a MacBook Air (PlatiniumAir) which is about to celebrate its first anniversary:
This morning while walking-reading in my room, I had iTunes on the MacBook playing some tracks from one of the auto-generated Apple Music playlists. Now, it’s fairly easy to flick away mobile (lying away on my desk) notifications using my watch and not interrupt my reading for more than a couple seconds. But it was annoying to go back to my desk, login to the machine and skip a track when I did not like the one that played automatically. I wondered, if the watch could interface with my MacBook somehow and I could achieve what I wanted.
I first tried adding the MacBook as a bluetooth device to the watch, but that didn’t seem to help.
A couple Google searches later I found an Android app called Mac Remote for Wear which seemed promising. It’s a no frills app which requires you to enable remote logging into your machine, supply the username, password and local IP address of your machine and configure any app like iTunes, VLC, etc. using AppleScript. Once that is done, it appears similar to following screen on your Android Wear device:
What prompted me to write this post, however, was not this app, but finally spending some time with AppleScript and learning of its power.
Turns out it’s easy to play with AppleScript using a terminal, try the following one liner, for example:
$ osascript -e ‘tell application “iTunes” to playpause’
Script Editor, an application shipped by default on OS X, provides complete reference (dictionary in AppleScript parlance) for each installed application’s API. It was a matter of few minutes to figure out how to make those buttons play well with iTunes:
I had read about AppleScript being used for automation on OS X, but had never bothered to give it a try in my almost one year’s experience with the Mac world. This simple use case today served as my first introduction to AS. Hope to automate a lot more things in future on OS X.