Shell script to control iTunes from the command-line.
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
t
Changes
README.mkdn
itunes

README.mkdn

Bash iTunes

Bash iTunes is a command-line wrapper for iTunes, letting you easily control iTunes from the terminal or over SSH.

Currently it supports the following commands:

Navigation commands:
    play        Start or resume playing.
    pause       Pause playing.
    stop        Stop playing.
    next        Skip to next track.
    prev        Skip back to previous track.
    info        View info about current track.
    search      Search for tracks.
    shuffle     View or set shuffle status.
    repeat      View or set repeat status.
    playlist    View or choose playlist.
    playlists   List all playlists.

Volume commands:
    vol[ume]    View or adjust iTunes volume 'up', 'down' or percentage.
    mute        Mutes iTunes.
    unmute      Unmutes iTunes, restoring previous volume level.
    sysvol[ume] View or adjust system volume 'up', 'down' or percentage.
    sysmute     Mute system sound.
    sysunmute   Unmute system sound.

Application commands:
    open        Start iTunes running.
    quit        Quit iTunes.
    show        Hide the iTunes window.
    hide        Show the iTunes window.

Additional commands:
    version     Show version information and exit.
    help        Show this help and exit.
    plugins     Show a list of plugins installed.

Setup

Install the itunes script somewhere on your path, ~/bin is the usual choice, and type itunes help to get started.

Have fun.

Plugin Support

bash-itunes has rudimentary plugin support by creating subcommands in the $HOME/.bash-itunes/plugins directory:

  1. Create a bash script in the plugins directory named after the command name.
  2. In the main body of the script do nothing but set the PLUGIN_NAME (a full name for the plugin), PLUGIN_VERSION (the plugin version) and PLUGIN_BRIEF (an under 70-char single-line description of the plugin) variables.
  3. Create a bash function named _cmd_<plugin_name> that performs the command.

For a simple example, $HOME/.bash-itunes/plugins/party:

#!/bin/bash

PLUGIN_NAME="Party Party!"
PLUGIN_VERSION="1.0.1"
PLUGIN_BRIEF="Gets the party started in style."

function _cmd_party() {
    say -v zarvox "Party party!" &
    echo "Party party!"
}

Results in the following:

$ itunes plugins
Installed plugins:
  party - Party Party! (1.0.1)

$ itunes party
Party party!

For a more extensive tutorial on writing plugins, check the blog entry on my website: http://www.illusori.co.uk/blog/2012/06/15/bash_itunes_plugin_tutorial.html