Improve UX for Spotify commands in osx plugin

Spotify command UX is a little weak for people who live and work almost entirely in shells.
- `spotify quit` should not open Spotify if it is not already running. Should confirm that Spotify is indeed not running.
- `spotify quit` should not blow away the user's shell once Spotify is quit. This can be a disruption to work flow.

This PR looks to add a few little checks which will help improve this experience.
This PR also adds a space to line 477 between `break` and `;;` for consistency. Doesn't seem like a big enough change to put in its own PR.
This commit is contained in:
Ryan Brushett 2016-12-20 14:10:45 -05:00
commit ed4c40e340
No known key found for this signature in database
GPG key ID: 033C82F944B6317F

View file

@ -323,7 +323,7 @@ function spotify() {
if [ $# = 0 ]; then if [ $# = 0 ]; then
showHelp; showHelp;
else 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' osascript -e 'tell application "Spotify" to activate'
sleep 2 sleep 2
fi fi
@ -414,8 +414,12 @@ function spotify() {
"quit" ) "quit" )
cecho "Quitting Spotify."; cecho "Quitting Spotify.";
osascript -e 'tell application "Spotify" to quit'; if [ "$(osascript -e 'application "Spotify" is running')" = "false" ]; then
exit 1 ;; cecho "Spotify was not running."
else
osascript -e 'tell application "Spotify" to quit';
fi
break ;;
"next" ) "next" )
cecho "Going to next track." ; cecho "Going to next track." ;
@ -470,7 +474,7 @@ function spotify() {
"pos" ) "pos" )
cecho "Adjusting Spotify play position." cecho "Adjusting Spotify play position."
osascript -e "tell application \"Spotify\" to set player position to $2"; osascript -e "tell application \"Spotify\" to set player position to $2";
break;; break ;;
"status" ) "status" )
showStatus; showStatus;