Commit 73b0e4c7 authored by Dylan's avatar Dylan

[Linux] Added spotify support to getsong

parent 554d65de
...@@ -1075,6 +1075,21 @@ getsong () { ...@@ -1075,6 +1075,21 @@ getsong () {
song="$(mocp -Q "%artist - %song" 2>/dev/null)" song="$(mocp -Q "%artist - %song" 2>/dev/null)"
state="$(mocp -Q "%state" 2>/dev/null)" state="$(mocp -Q "%state" 2>/dev/null)"
elif pgrep "spotify" >/dev/null 2>&1; then
case "$os" in
"Linux")
# This command is way too long
song="$(\
dbus-send --print-reply --dest=org.mpris.MediaPlayer2.spotify /org/mpris/MediaPlayer2 \
org.freedesktop.DBus.Properties.Get string:'org.mpris.MediaPlayer2.Player' string:'Metadata' |\
awk -F 'string "' '/string|array/ {printf "%s",$2; next}{print ""}' |\
awk -F '"' '/artist|title/ {printf $2 " - "}'\
)"
song=${song% - }
song=${song/'('*}
song=${song//'['*}
;;
esac
else else
song="Unknown" song="Unknown"
fi fi
...@@ -1084,7 +1099,7 @@ getsong () { ...@@ -1084,7 +1099,7 @@ getsong () {
song="Paused" song="Paused"
;; ;;
"stopped" | "STOP" | "") "stopped" | "STOP")
song="Stopped" song="Stopped"
;; ;;
esac esac
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment