fixed cmus properly, now works regardless of output order

This commit is contained in:
Andrew Titmuss 2016-06-05 08:03:50 +10:00
parent bdc445cc6f
commit 8d88fe172e
No known key found for this signature in database
GPG key ID: 8AF42975C787E0B2

View file

@ -1452,10 +1452,16 @@ getsong () {
state=$(mpc | awk -F '\\[|\\]' '/\[/ {printf $2}' 2>/dev/null) state=$(mpc | awk -F '\\[|\\]' '/\[/ {printf $2}' 2>/dev/null)
elif [ -n "$(ps x | awk '!(/awk/) && /cmus/')" ]; then elif [ -n "$(ps x | awk '!(/awk/) && /cmus/')" ]; then
song="$(cmus-remote -Q | grep "tag artist \|title" 2>/dev/null)" song="$(cmus-remote -Q | grep "tag artist \|title" 2>/dev/null | tr -d '\012')"
artist="${song##*tag artist }" if [ "$(printf "$song" | awk '{print $2}')" == "title" ]; then
title="${song##*tag title }" artist="${song##*tag artist }"
title="${title%%tag artist*}" title="${song##*tag title }"
title="${title%%tag artist*}"
else
artist="${song##tag artist }"
artist="${artist%%tag title*}"
title="${song##*tag title }"
fi
song="$artist - $title" song="$artist - $title"
state=$(cmus-remote -Q | awk -F ' ' '/status/ {printf $2}' 2>/dev/null) state=$(cmus-remote -Q | awk -F ' ' '/status/ {printf $2}' 2>/dev/null)