Merge pull request #271 from iandrewt/cmus-fix

fixed cmus properly, now works regardless of output order
This commit is contained in:
Dylan Araps 2016-06-05 09:19:51 +10:00
commit 80a73320ae
1 changed files with 6 additions and 5 deletions

View File

@ -1454,12 +1454,13 @@ 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)" IFS=$'\n'
artist="${song##*tag artist }" song=($(cmus-remote -Q | grep "tag artist \|title \|status" 2>/dev/null | sort))
title="${song##*tag title }" artist=${song[1]/tag artist }
title="${title%%tag artist*}" title=${song[2]/tag title }
state=${song[0]/status }
song="$artist - $title" song="$artist - $title"
state=$(cmus-remote -Q | awk -F ' ' '/status/ {printf $2}' 2>/dev/null)
elif pgrep "mocp" >/dev/null 2>&1; then elif pgrep "mocp" >/dev/null 2>&1; then
song="$(mocp -Q "%artist - %song" 2>/dev/null)" song="$(mocp -Q "%artist - %song" 2>/dev/null)"