0d36ecfe387b164a13899ae2e7ac565b0abd0bbd
- Author
- Robby Russell <robby@planetargon.com>
- Committer
- Robby Russell <robby@planetargon.com>
- Date
Message
Merge pull request #2174 from oxnz/master
plugins/osx/osx.plugin.zsh: add itunes function to control itnues from the terminal
Diff
1diff --git a/plugins/osx/osx.plugin.zsh b/plugins/osx/osx.plugin.zsh
2index dd785f91131a3e9dd53f5f0e3f01378919c9f230..608ec378944d91220aea9c5de9622b7f055d6401 100644
3--- a/plugins/osx/osx.plugin.zsh
4+++ b/plugins/osx/osx.plugin.zsh
5@@ -157,3 +157,37 @@ function trash() {
6 function vncviewer() {
7 open vnc://$@
8 }
9+
10+# iTunes control function
11+function itunes() {
12+ local opt=$1
13+ shift
14+ case "$opt" in
15+ launch|play|pause|stop|rewind|resume|quit)
16+ ;;
17+ mute)
18+ opt="set mute to true"
19+ ;;
20+ unmute)
21+ opt="set mute to false"
22+ ;;
23+ next|previous)
24+ opt="$opt track"
25+ ;;
26+ ""|-h|--help)
27+ echo "Usage: itunes <option>"
28+ echo "option:"
29+ echo "\tlaunch|play|pause|stop|rewind|resume|quit"
30+ echo "\tmute|unmute\tcontrol volume set"
31+ echo "\tnext|previous\tplay next or previous track"
32+ echo "\thelp\tshow this message and exit"
33+ return 0
34+ ;;
35+ *)
36+ print "Unkonwn option: $opt"
37+ return 1
38+ ;;
39+ esac
40+ osascript -e "tell application \"iTunes\" to $opt"
41+}
42+