Dafacto

The personal website of Matt Henderson.

Control iTunes Remotely

I have iTunes running at home on a Mac mini, with a Harmon Kardon Soundsticks II system connected, and was looking for a way to control iTunes remotely, from another Mac. This page discusses setting up a PHP script on the remote machine, but involves some things I didn't like much (like running the web server as a normal user). Also, managing iTunes via web URLs isn't as convenient as I'd like.

What I finally decided to implement, was a number of shell scripts that can be run from QuickSilver. This works, is very convenient, and only relies on SSH key authentication (i.e. without password) to the remote machine.

Following are the shell scripts I now have. (Important: Note that the second and third lines of each script below are really one line in the shell script. I broke the line for display purposes here.)

With these in place, controlling iTunes remotely is a matter of command-space iNext return. Great!

  • iUp (increase the volume)

    #!/bin/bash ssh 192.168.2.130 "osascript -e 'tell application "iTunes" to set sound volume to sound volume + 5'"

  • iDown (decrease the volume)

    #!/bin/bash ssh 192.168.2.130 "osascript -e 'tell application "iTunes" to set sound volume to sound volume - 5'"

  • iNext (next song)

    #!/bin/bash ssh 192.168.2.130 "osascript -e 'tell application "iTunes" to next track'"

  • iPrev (previous song)

    #!/bin/bash ssh 192.168.2.130 "osascript -e 'tell application "iTunes" to previous track'"

  • iPause (pause)

    #!/bin/bash ssh 192.168.2.130 "osascript -e 'tell application "iTunes" to pause'"

  • iPlay (play)

    #!/bin/bash ssh 192.168.2.130 "osascript -e 'tell application "iTunes" to play'"

  • iQuit (quit iTunes)

    #!/bin/bash ssh 192.168.2.130 "osascript -e 'tell application "iTunes" to quit'"

  • iStart (start iTunes)

    #!/bin/bash ssh 192.168.2.130 "osascript -e 'tell application "iTunes" to start'"

Enjoy this article? — You can find similar content via the category and tag links below.

Categories — Technology

Tags — Geek, Apple

Questions or comments? — Feel free to email me using the contact form below, or reach out on Twitter.