diff options
author | Robby Russell <robby@planetargon.com> | 2017-02-27 09:02:16 -0800 |
---|---|---|
committer | Robby Russell <robby@planetargon.com> | 2017-02-27 09:02:16 -0800 |
commit | b908feebcfb0ca8a9a80360d177e716c24c317d6 (patch) | |
tree | 966fd789c3bcdf804d6d242a3becf81afc343eaa /plugins/osx | |
parent | e609fd5a9f7f7c9a16945ca9c0748b6de99f6635 (diff) | |
parent | d874c73f19d8430f4dc32756fff0bf2f6a804d87 (diff) | |
download | zsh-b908feebcfb0ca8a9a80360d177e716c24c317d6.tar.gz zsh-b908feebcfb0ca8a9a80360d177e716c24c317d6.tar.bz2 zsh-b908feebcfb0ca8a9a80360d177e716c24c317d6.zip |
Merge branch 'master' of github.com:robbyrussell/oh-my-zsh
Diffstat (limited to 'plugins/osx')
-rw-r--r-- | plugins/osx/osx.plugin.zsh | 29 |
1 files changed, 24 insertions, 5 deletions
diff --git a/plugins/osx/osx.plugin.zsh b/plugins/osx/osx.plugin.zsh index d7baa1191..e8488ebc9 100644 --- a/plugins/osx/osx.plugin.zsh +++ b/plugins/osx/osx.plugin.zsh @@ -184,6 +184,7 @@ function vncviewer() { # iTunes control function function itunes() { local opt=$1 + local playlist=$2 shift case "$opt" in launch|play|pause|stop|rewind|resume|quit) @@ -200,6 +201,19 @@ function itunes() { vol) opt="set sound volume to $1" #$1 Due to the shift ;; + playlist) + # Inspired by: https://gist.github.com/nakajijapan/ac8b45371064ae98ea7f +if [[ ! -z "$playlist" ]]; then + osascript -e 'tell application "iTunes"' -e "set new_playlist to \"$playlist\" as string" -e "play playlist new_playlist" -e "end tell" 2>/dev/null; + if [[ $? -eq 0 ]]; then + opt="play" + else + opt="stop" + fi + else + opt="set allPlaylists to (get name of every playlist)" + fi + ;; playing|status) local state=`osascript -e 'tell application "iTunes" to player state as string'` if [[ "$state" = "playing" ]]; then @@ -250,6 +264,7 @@ EOF echo "\tshuf|shuffle [on|off|toggle]\tSet shuffled playback. Default: toggle. Note: toggle doesn't support the MiniPlayer." echo "\tvol\tSet the volume, takes an argument from 0 to 100" echo "\tplaying|status\tShow what song is currently playing in iTunes." + echo "\tplaylist [playlist name]\t Play specific playlist" echo "\thelp\tshow this message and exit" return 0 ;; @@ -323,7 +338,7 @@ function spotify() { if [ $# = 0 ]; then showHelp; else - if [ "$(osascript -e 'application "Spotify" is running')" = "false" ]; then + if [ "$1" != "quit" ] && [ "$(osascript -e 'application "Spotify" is running')" = "false" ]; then osascript -e 'tell application "Spotify" to activate' sleep 2 fi @@ -413,9 +428,13 @@ function spotify() { break ;; "quit" ) - cecho "Quitting Spotify."; - osascript -e 'tell application "Spotify" to quit'; - exit 1 ;; + if [ "$(osascript -e 'application "Spotify" is running')" = "false" ]; then + cecho "Spotify was not running." + else + cecho "Closing Spotify."; + osascript -e 'tell application "Spotify" to quit'; + fi + break ;; "next" ) cecho "Going to next track." ; @@ -470,7 +489,7 @@ function spotify() { "pos" ) cecho "Adjusting Spotify play position." osascript -e "tell application \"Spotify\" to set player position to $2"; - break;; + break ;; "status" ) showStatus; |