Created
April 4, 2010 09:04
-
-
Save ishikawa/355256 to your computer and use it in GitHub Desktop.
itunes.sh - control your iTunes from shell
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#/bin/bash | |
# | |
# itunes.sh - Control Your iTunes from shell | |
# | |
TRACK_PROGRAM=`cat <<EOS | |
tell current track | |
name & " - " & artist | |
end tell | |
EOS` | |
case "$1" in | |
-h|help) | |
cat <<USAGE | |
usage: itunes.sh [OPTIONS] | |
OPTIONS: | |
play/pause|stop Toggle the playing/paused state | |
next Advance to the next track in the current playlist | |
prev Return to the previous track in the current playlist | |
track Show information of the current track | |
shuffle (on|off) Play the songs in this playlist in random order? | |
+n/-n Increase/Decrease the current volume | |
volume The sound output volume (0 = minimum, 100 = maximum) | |
volume Show the current volume | |
volume 15 Set the current volume to 15 | |
volume +10 Increase the current volume | |
volume -10 Decrease the current volume | |
-h|help Show this help | |
USAGE | |
exit 0 ;; | |
play|pause|stop) | |
PROGRAM="playpause" ;; | |
next) | |
PROGRAM=`cat <<EOS | |
next track | |
$TRACK_PROGRAM | |
EOS` | |
;; | |
prev) | |
PROGRAM=`cat <<EOS | |
previous track | |
$TRACK_PROGRAM | |
EOS` | |
;; | |
track) | |
PROGRAM="$TRACK_PROGRAM" | |
;; | |
shuffle) | |
shift | |
case "$1" in | |
yes|on) | |
PROGRAM="set shuffle of current playlist to true" ;; | |
no|off) | |
PROGRAM="set shuffle of current playlist to false" ;; | |
*) | |
PROGRAM="get shuffle of current playlist" | |
esac | |
;; | |
+*|-*) | |
PROGRAM="set sound volume to sound volume $1 $2" ;; | |
volume) | |
shift | |
case "$1" in | |
+*|-*) | |
PROGRAM="set sound volume to sound volume $1 $2" ;; | |
*) | |
if [ -z "$1" ]; then | |
PROGRAM="get sound volume" | |
else | |
PROGRAM="set sound volume to $1" | |
fi | |
esac | |
;; | |
esac | |
PROGRAM=`cat <<EOS | |
tell application "iTunes" | |
$PROGRAM | |
end tell | |
EOS` | |
exec osascript -e "$PROGRAM" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment