From 8d88fe172eb0c29dea0d36f492f1cfc60355e1a6 Mon Sep 17 00:00:00 2001 From: Andrew Titmuss Date: Sun, 5 Jun 2016 08:03:50 +1000 Subject: [PATCH 1/2] fixed cmus properly, now works regardless of output order --- neofetch | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/neofetch b/neofetch index 41fab14f..21861544 100755 --- a/neofetch +++ b/neofetch @@ -1452,10 +1452,16 @@ getsong () { state=$(mpc | awk -F '\\[|\\]' '/\[/ {printf $2}' 2>/dev/null) elif [ -n "$(ps x | awk '!(/awk/) && /cmus/')" ]; then - song="$(cmus-remote -Q | grep "tag artist \|title" 2>/dev/null)" - artist="${song##*tag artist }" - title="${song##*tag title }" - title="${title%%tag artist*}" + song="$(cmus-remote -Q | grep "tag artist \|title" 2>/dev/null | tr -d '\012')" + if [ "$(printf "$song" | awk '{print $2}')" == "title" ]; then + artist="${song##*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" state=$(cmus-remote -Q | awk -F ' ' '/status/ {printf $2}' 2>/dev/null) From e2e74f1de3828fffc9964d7db6ec7777de17e4ef Mon Sep 17 00:00:00 2001 From: Andrew Titmuss Date: Sun, 5 Jun 2016 09:07:47 +1000 Subject: [PATCH 2/2] cmus now works with only 1 call for entire block --- neofetch | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) diff --git a/neofetch b/neofetch index 21861544..c12b3d7e 100755 --- a/neofetch +++ b/neofetch @@ -1452,18 +1452,13 @@ getsong () { state=$(mpc | awk -F '\\[|\\]' '/\[/ {printf $2}' 2>/dev/null) elif [ -n "$(ps x | awk '!(/awk/) && /cmus/')" ]; then - song="$(cmus-remote -Q | grep "tag artist \|title" 2>/dev/null | tr -d '\012')" - if [ "$(printf "$song" | awk '{print $2}')" == "title" ]; then - artist="${song##*tag artist }" - title="${song##*tag title }" - title="${title%%tag artist*}" - else - artist="${song##tag artist }" - artist="${artist%%tag title*}" - title="${song##*tag title }" - fi + IFS=$'\n' + song=($(cmus-remote -Q | grep "tag artist \|title \|status" 2>/dev/null | sort)) + artist=${song[1]/tag artist } + title=${song[2]/tag title } + state=${song[0]/status } + song="$artist - $title" - 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" 2>/dev/null)"