Detect iTunes/Spotify successfully when the other is not running

This commit is contained in:
Joseph Durel 2018-02-01 21:58:06 -05:00
parent b76513d7b6
commit be893d48c3
1 changed files with 12 additions and 8 deletions

View File

@ -1522,7 +1522,7 @@ get_memory() {
} }
get_song() { get_song() {
player="$(ps -e | grep -m 1 -o -F \ player="$(ps -e | grep -m 1 -o \
-e "Google Play" \ -e "Google Play" \
-e "Spotify" \ -e "Spotify" \
-e "amarok" \ -e "amarok" \
@ -1537,7 +1537,7 @@ get_song() {
-e "exaile" \ -e "exaile" \
-e "gnome-music" \ -e "gnome-music" \
-e "guayadeque" \ -e "guayadeque" \
-e "iTunes.app" \ -e "iTunes$" \
-e "juk" \ -e "juk" \
-e "lollypop" \ -e "lollypop" \
-e "mocp" \ -e "mocp" \
@ -1604,9 +1604,11 @@ get_song() {
"Mac OS X") "Mac OS X")
song="$(osascript <<END song="$(osascript <<END
tell application "Spotify" if application "Spotify" is running then
artist of current track as string & " - " & name of current track as string tell application "Spotify"
end tell artist of current track as string & " - " & name of current track as string
end tell
end if
END END
)" )"
;; ;;
@ -1615,9 +1617,11 @@ END
"itunes"*) "itunes"*)
song="$(osascript <<END song="$(osascript <<END
tell application "iTunes" if application "iTunes" is running then
artist of current track as string & " - " & name of current track as string tell application "iTunes"
end tell artist of current track as string & " - " & name of current track as string
end tell
end if
END END
)" )"
;; ;;