From 362cbb5b7d06f741e15681c8c4747a9da4b2b4b1 Mon Sep 17 00:00:00 2001 From: Dylan Date: Tue, 16 Feb 2016 14:50:20 +1100 Subject: [PATCH] Add playback state to getsong --- fetch | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/fetch b/fetch index 8a270fd1..20e87250 100755 --- a/fetch +++ b/fetch @@ -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 } # }}}