Add playback state to getsong

This commit is contained in:
Dylan 2016-02-16 14:50:20 +11:00
parent b603d3395c
commit 362cbb5b7d
1 changed files with 16 additions and 3 deletions

19
fetch
View File

@ -1099,20 +1099,33 @@ getmemory () {
getsong () {
if pgrep "mpd" >/dev/null 2>&1; then
song="$(mpc current)"
song="$(mpc current 2>/dev/null)"
state=$(mpc | awk -F '\\[|\\]' '/\[/ {printf $2}' 2>/dev/null)
elif pgrep "cmus" >/dev/null 2>&1; then
song="$(cmus-remote -Q | grep "tag artist\|title")"
song="$(cmus-remote -Q | grep "tag artist\|title" 2>/dev/null)"
song=${song/tag artist }
song=${song/tag title/-}
song=${song//[[:space:]]/ }
state=$(cmus-remote -Q | awk -F ' ' '/status/ {printf $2}' 2>/dev/null)
elif pgrep "mocp" >/dev/null 2>&1; then
song="$(mocp -Q "%artist - %song")"
song="$(mocp -Q "%artist - %song" 2>/dev/null)"
state="$(mocp -Q "%state" 2>/dev/null)"
else
song="Unknown"
fi
case "$state" in
"paused" | "PAUSE")
song="Paused"
;;
"stopped" | "STOP" | "")
song="Stopped"
;;
esac
}
# }}}