Optimal Telelicious Coding From AK To CT
 
« Curl Multi Php Download How-To
Finding Duplicate Lines with Regex »
 

How To Control iTunes remotely with SSH

After chatting with my buddy Dave about how awesome it is to show off using terminal to !1337 computer users I realized how often I’m sitting at command-line listening to music in iTunes and wondered how to control iTunes with a shell script.

I searched around an found this article on the topic but of course wanted many tweaks of my own so I’ve wrote the following script that should allow anyone to control iTunes in terminal or via SSH remotely.

Possible Uses

The implications are pretty neat if you think about it.

  • DJ a party from a laptop, iPhone, or mobile with SSH
  • Control your home or office music server remotely
  • Scare the heck out of your roommates

The Code

#!/bin/sh
#
####################################
# iTunes Command Line Control v1.0
# written by David Schlosnagle
# created 2001.11.08
# edited by Jon Todd 2007.11.20
####################################

showHelp () {
echo "-----------------------------";
echo "iTunes Command Line Interface";
echo "-----------------------------";
echo "Usage: `basename $0` 

Installation

Write this code to a file called “itunes” and put it in your bin directory

mkdir ~/bin
mv pathToFile/itunes.sh ~/bin
chmod u+x ~/bin/itunes

Ensure ~/bin is in your path

Run it

[jtodd@local:~]$ itunes status
State:      stopped
Volume:     100
Playlist:   Combo
Shuffle:    false
[jtodd@local:~]$ itunes play
Playing iTunes.
[jtodd@local:~]$ itunes status
State:      playing
Volume:     100
Playlist:   Combo
Shuffle:    false
Artist:     Jamiroquai
Album:      synkronized
Track:      Canned Heat
[jtodd@local:~]$ itunes vol 50
Changing iTunes volume level.
[jtodd@local:~]$ itunes pause
Pausing iTunes.
[jtodd@local:~]$ itunes vol 100
Changing iTunes volume level.
[jtodd@local:~]$ itunes play
Playing iTunes.

Remote Control

[jtodd@remote:~]$ ssh local
[jtodd@local:~]$ itunes status
State:      playing
Volume:     100
Playlist:   Combo
Shuffle:    false
Artist:     Jamiroquai
Album:      synkronized
Track:      Canned Heat

Tags: , , , , ,

Leave a Reply