From 9b94195ed92fe086bb95a1bd8b6e726028ef4e69 Mon Sep 17 00:00:00 2001 From: Andrew Titmuss Date: Sat, 7 Oct 2017 16:18:07 +1100 Subject: [PATCH 1/9] add album to song name for some players --- neofetch | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/neofetch b/neofetch index 0ce2959d..82ec4cfa 100755 --- a/neofetch +++ b/neofetch @@ -1423,7 +1423,7 @@ guayadeque|yarock|qmmp|quodlibet|deepin-music|tomahawk|pogo|elisa/ {printf $5 " org.freedesktop.DBus.Properties.Get string:'org.mpris.MediaPlayer2.Player' \ string:'Metadata' |\ awk -F 'string "' '/string|array/ {printf "%s",$2; next}{print ""}' |\ - awk -F '"' '/artist/ {a=$2} /title/ {t=$2} END{print a " - " t}' + awk -F '"' '/artist/ {a=$2} /album"/ {b=$2} /title/ {t=$2} END{print a " - " b " - " t}' )" } @@ -1450,13 +1450,14 @@ guayadeque|yarock|qmmp|quodlibet|deepin-music|tomahawk|pogo|elisa/ {printf $5 " song="$(audtool current-song)" # Remove Album from 'Artist - Album - Title' - song="${song/-* -/-}" + #song="${song/-* -/-}" [[ -z "$song" ]] && get_song_dbus "audacious" ;; "cmus"*) song="$(cmus-remote -Q | awk '/tag artist/ {$1=$2=""; print; print " - "}\ + /tag album/ {$1=$2=""; print; print " - "}\ /tag title/ {$1=$2=""; print}')" ;; @@ -1465,14 +1466,16 @@ guayadeque|yarock|qmmp|quodlibet|deepin-music|tomahawk|pogo|elisa/ {printf $5 " "Linux") get_song_dbus "spotify" ;; "Mac OS X") - song="$(osascript -e 'tell application "Spotify" to artist of current track as \ + song="$(osascript -e 'tell application "Spotify" to artist of current track as¬ + string & " - " & album of current track as¬ string & " - " & name of current track as string')" ;; esac ;; "itunes"*) - song="$(osascript -e 'tell application "iTunes" to artist of current track as \ + song="$(osascript -e 'tell application "iTunes" to artist of current track as¬ + string & " - " & album of current track as¬ string & " - " & name of current track as string')" ;; @@ -1514,13 +1517,16 @@ guayadeque|yarock|qmmp|quodlibet|deepin-music|tomahawk|pogo|elisa/ {printf $5 " [[ "$(trim "$song")" == "-" ]] && unset -v song - # Display Artist and Title on separate lines. + # Display Artist, Album and Title on separate lines. if [[ "$song_shorthand" == "on" && "$song" ]]; then artist="${song/ -*}" + album="${song#*- }" + album="${album% -*}" song="${song/*-}" if [[ "$song" != "$artist" ]]; then prin "Artist" "$artist" + prin "Album" "$album" prin "Song" "$song" else prin "$subtitle" "$song" From f1052a8e73c6fb07447da4bba1890d67887aa149 Mon Sep 17 00:00:00 2001 From: Andrew Titmuss Date: Fri, 13 Oct 2017 13:35:10 +1100 Subject: [PATCH 2/9] fix cmus album output (hopefully) --- neofetch | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/neofetch b/neofetch index 82ec4cfa..e6678153 100755 --- a/neofetch +++ b/neofetch @@ -1427,6 +1427,8 @@ guayadeque|yarock|qmmp|quodlibet|deepin-music|tomahawk|pogo|elisa/ {printf $5 " )" } + player="cmus" + case "${player/*\/}" in "mpd"* | "mopidy"*) song="$(mpc current)" ;; "mocp"*) song="$(mocp -Q "%artist - %song")" ;; @@ -1456,9 +1458,11 @@ guayadeque|yarock|qmmp|quodlibet|deepin-music|tomahawk|pogo|elisa/ {printf $5 " ;; "cmus"*) - song="$(cmus-remote -Q | awk '/tag artist/ {$1=$2=""; print; print " - "}\ - /tag album/ {$1=$2=""; print; print " - "}\ - /tag title/ {$1=$2=""; print}')" + song="$(cmus-remote -Q | awk 'BEGIN { ORS=" "}; + /tag artist/ {$1=$2=""; sub(" ", ""); a=$0}\ + /tag album/ {$1=$2=""; sub(" ", ""); b=$0}\ + /tag title/ {$1=$2=""; sub(" ", ""); t=$0}\ + END { print a " - " b " - " t }')" ;; "spotify"*) From 1f482d786c21bc1fd339a6505fc93c48f90faff5 Mon Sep 17 00:00:00 2001 From: Andrew Titmuss Date: Fri, 13 Oct 2017 13:38:08 +1100 Subject: [PATCH 3/9] remove a debug line for cmus (oops) --- neofetch | 2 -- 1 file changed, 2 deletions(-) diff --git a/neofetch b/neofetch index e6678153..e244e754 100755 --- a/neofetch +++ b/neofetch @@ -1427,8 +1427,6 @@ guayadeque|yarock|qmmp|quodlibet|deepin-music|tomahawk|pogo|elisa/ {printf $5 " )" } - player="cmus" - case "${player/*\/}" in "mpd"* | "mopidy"*) song="$(mpc current)" ;; "mocp"*) song="$(mocp -Q "%artist - %song")" ;; From 8ff013e73446a90b57943446921f8bd89d6c4db2 Mon Sep 17 00:00:00 2001 From: Michael Straube Date: Mon, 25 Dec 2017 09:31:04 +0100 Subject: [PATCH 4/9] song: add album for some players pogo exaile quodlibet pragha amarok deadbeef qmmp xmms2d mocp rhythmbox banshee mpd --- neofetch | 41 +++++++++++++++++++++-------------------- 1 file changed, 21 insertions(+), 20 deletions(-) diff --git a/neofetch b/neofetch index e244e754..d7e6b422 100755 --- a/neofetch +++ b/neofetch @@ -1428,13 +1428,13 @@ guayadeque|yarock|qmmp|quodlibet|deepin-music|tomahawk|pogo|elisa/ {printf $5 " } case "${player/*\/}" in - "mpd"* | "mopidy"*) song="$(mpc current)" ;; - "mocp"*) song="$(mocp -Q "%artist - %song")" ;; + "mpd"* | "mopidy"*) song="$(mpc -f '%artist% - %album% - %title%' current)" ;; + "mocp"*) song="$(mocp -Q "%artist - %album - %song")" ;; "google play"*) song="$(gpmdp-remote current)" ;; - "rhythmbox"*) song="$(rhythmbox-client --print-playing)" ;; - "deadbeef"*) song="$(deadbeef --nowplaying-tf '%artist% - %title%')" ;; - "xmms2d"*) song="$(xmms2 current -f '${artist} - ${title}')" ;; - "qmmp"*) song="$(qmmp --nowplaying '%p - %t')" ;; + "rhythmbox"*) song="$(rhythmbox-client --print-playing-format '%ta - %at - %tt')" ;; + "deadbeef"*) song="$(deadbeef --nowplaying-tf '%artist% - %album% - %title%')" ;; + "xmms2d"*) song="$(xmms2 current -f '${artist} - ${album} - ${title}')" ;; + "qmmp"*) song="$(qmmp --nowplaying '%p - %a - %t')" ;; "gnome-music"*) get_song_dbus "GnomeMusic" ;; "lollypop"*) get_song_dbus "Lollypop" ;; "clementine"*) get_song_dbus "clementine" ;; @@ -1448,10 +1448,6 @@ guayadeque|yarock|qmmp|quodlibet|deepin-music|tomahawk|pogo|elisa/ {printf $5 " "audacious"*) song="$(audtool current-song)" - - # Remove Album from 'Artist - Album - Title' - #song="${song/-* -/-}" - [[ -z "$song" ]] && get_song_dbus "audacious" ;; @@ -1482,41 +1478,46 @@ guayadeque|yarock|qmmp|quodlibet|deepin-music|tomahawk|pogo|elisa/ {printf $5 " ;; "banshee"*) - song="$(banshee --query-artist --query-title |\ - awk -F':' '/^artist/ {a=$2} /^title/ {t=$2} END{print a " - " t}')" + song="$(banshee --query-artist --query-album --query-title |\ + awk -F':' '/^artist/ {a=$2} /^album/ {b=$2} /^title/ {t=$2} + END{print a " - " b " - "t}')" ;; "amarok"*) song="$(qdbus org.kde.amarok /Player GetMetadata |\ - awk -F':' '/^artist/ {a=$2} /^title/ {t=$2} END{print a " - " t}')" + awk -F':' '/^artist:/ {a=$2} /^album:/ {b=$2} /^title:/ {t=$2} + END{print a " - " b " - " t}')" ;; "pragha"*) - song="$(pragha -c | awk -F':' '/^artist/ {a=$2} /^title/ {t=$2} END{print a " - " t}')" + song="$(pragha -c | awk -F':' '/^artist/ {a=$2} /^album/ {b=$2} /^title/ {t=$2} + END{print a " - " b " - " t}')" ;; "exaile"*) song="$(dbus-send --print-reply --dest=org.exaile.Exaile /org/exaile/Exaile \ - org.exaile.Exaile.Query | awk -F':|,' '{if ($6 && $4) printf $6 " -" $4}')" + org.exaile.Exaile.Query | + awk -F':|,' '{if ($6 && $8 && $4) printf $6 " -" $8 " -" $4}')" ;; "quodlibet"*) song="$(dbus-send --print-reply --dest=net.sacredchao.QuodLibet \ /net/sacredchao/QuodLibet net.sacredchao.QuodLibet.CurrentSong |\ - awk -F'"' '/artist/ {getline; a=$2} \ - /title/ {getline; t=$2} END{print a " - " t}')" + awk -F'"' '/artist/ {getline; a=$2} /album/ {getline; b=$2} + /title/ {getline; t=$2} END{print a " - " b " - " t}')" ;; "pogo"*) song="$(dbus-send --print-reply --dest=org.mpris.pogo /Player \ org.freedesktop.MediaPlayer.GetMetadata | - awk -F'"' '/string "artist"/ {getline; a=$2} /string "title"/ {getline; t=$2} \ - END{print a " - " t}')" + awk -F'"' '/string "artist"/ {getline; a=$2} /string "album"/ {getline; b=$2} \ + /string "title"/ {getline; t=$2} END{print a " - " b " - " t}')" ;; - *) mpc >/dev/null 2>&1 && song="$(mpc current)" ;; + *) mpc >/dev/null 2>&1 && song="$(mpc -f '%artist% - %album% - %title%' current)" ;; esac + # TODO: adjust for album: "$(trim "$song")" == "- -" [[ "$(trim "$song")" == "-" ]] && unset -v song # Display Artist, Album and Title on separate lines. From 31ccd633d28773bec4993eed93f9c5aeb06c7789 Mon Sep 17 00:00:00 2001 From: Michael Straube Date: Tue, 26 Dec 2017 09:22:03 +0100 Subject: [PATCH 5/9] song: fix cmus album --- neofetch | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/neofetch b/neofetch index d7e6b422..f8c7691e 100755 --- a/neofetch +++ b/neofetch @@ -1454,7 +1454,7 @@ guayadeque|yarock|qmmp|quodlibet|deepin-music|tomahawk|pogo|elisa/ {printf $5 " "cmus"*) song="$(cmus-remote -Q | awk 'BEGIN { ORS=" "}; /tag artist/ {$1=$2=""; sub(" ", ""); a=$0}\ - /tag album/ {$1=$2=""; sub(" ", ""); b=$0}\ + /tag album / {$1=$2=""; sub(" ", ""); b=$0}\ /tag title/ {$1=$2=""; sub(" ", ""); t=$0}\ END { print a " - " b " - " t }')" ;; From 3ece779d4778e906d26d9126596307cd5b499e57 Mon Sep 17 00:00:00 2001 From: Dylan Araps Date: Wed, 9 May 2018 18:26:31 +1000 Subject: [PATCH 6/9] song: Fix issues with splitting. --- neofetch | 59 ++++++++++++++++++++++++++------------------------------ 1 file changed, 27 insertions(+), 32 deletions(-) diff --git a/neofetch b/neofetch index f8c7691e..aa9975a1 100755 --- a/neofetch +++ b/neofetch @@ -1423,18 +1423,18 @@ guayadeque|yarock|qmmp|quodlibet|deepin-music|tomahawk|pogo|elisa/ {printf $5 " org.freedesktop.DBus.Properties.Get string:'org.mpris.MediaPlayer2.Player' \ string:'Metadata' |\ awk -F 'string "' '/string|array/ {printf "%s",$2; next}{print ""}' |\ - awk -F '"' '/artist/ {a=$2} /album"/ {b=$2} /title/ {t=$2} END{print a " - " b " - " t}' + awk -F '"' '/artist/ {a=$2} /album"/ {b=$2} /title/ {t=$2} END{print a " ‡ " b " ‡ " t}' )" } case "${player/*\/}" in - "mpd"* | "mopidy"*) song="$(mpc -f '%artist% - %album% - %title%' current)" ;; - "mocp"*) song="$(mocp -Q "%artist - %album - %song")" ;; + "mpd"* | "mopidy"*) song="$(mpc -f '%artist% ‡ %album% ‡ %title%' current)" ;; + "mocp"*) song="$(mocp -Q "%artist ‡ %album ‡ %song")" ;; "google play"*) song="$(gpmdp-remote current)" ;; - "rhythmbox"*) song="$(rhythmbox-client --print-playing-format '%ta - %at - %tt')" ;; - "deadbeef"*) song="$(deadbeef --nowplaying-tf '%artist% - %album% - %title%')" ;; - "xmms2d"*) song="$(xmms2 current -f '${artist} - ${album} - ${title}')" ;; - "qmmp"*) song="$(qmmp --nowplaying '%p - %a - %t')" ;; + "rhythmbox"*) song="$(rhythmbox-client --print-playing-format '%ta ‡ %at ‡ %tt')" ;; + "deadbeef"*) song="$(deadbeef --nowplaying-tf '%artist% ‡ %album% ‡ %title%')" ;; + "xmms2d"*) song="$(xmms2 current -f '${artist} ‡ ${album} ‡ ${title}')" ;; + "qmmp"*) song="$(qmmp --nowplaying '%p ‡ %a ‡ %t')" ;; "gnome-music"*) get_song_dbus "GnomeMusic" ;; "lollypop"*) get_song_dbus "Lollypop" ;; "clementine"*) get_song_dbus "clementine" ;; @@ -1456,7 +1456,7 @@ guayadeque|yarock|qmmp|quodlibet|deepin-music|tomahawk|pogo|elisa/ {printf $5 " /tag artist/ {$1=$2=""; sub(" ", ""); a=$0}\ /tag album / {$1=$2=""; sub(" ", ""); b=$0}\ /tag title/ {$1=$2=""; sub(" ", ""); t=$0}\ - END { print a " - " b " - " t }')" + END { print a " ‡ " b " ‡ " t }')" ;; "spotify"*) @@ -1465,75 +1465,70 @@ guayadeque|yarock|qmmp|quodlibet|deepin-music|tomahawk|pogo|elisa/ {printf $5 " "Mac OS X") song="$(osascript -e 'tell application "Spotify" to artist of current track as¬ - string & " - " & album of current track as¬ - string & " - " & name of current track as string')" + string & " ‡ " & album of current track as¬ + string & " ‡ " & name of current track as string')" ;; esac ;; "itunes"*) song="$(osascript -e 'tell application "iTunes" to artist of current track as¬ - string & " - " & album of current track as¬ - string & " - " & name of current track as string')" + string & " ‡ " & album of current track as¬ + string & " ‡ " & name of current track as string')" ;; "banshee"*) song="$(banshee --query-artist --query-album --query-title |\ awk -F':' '/^artist/ {a=$2} /^album/ {b=$2} /^title/ {t=$2} - END{print a " - " b " - "t}')" + END{print a " ‡ " b " ‡ "t}')" ;; "amarok"*) song="$(qdbus org.kde.amarok /Player GetMetadata |\ awk -F':' '/^artist:/ {a=$2} /^album:/ {b=$2} /^title:/ {t=$2} - END{print a " - " b " - " t}')" + END{print a " ‡ " b " ‡ " t}')" ;; "pragha"*) song="$(pragha -c | awk -F':' '/^artist/ {a=$2} /^album/ {b=$2} /^title/ {t=$2} - END{print a " - " b " - " t}')" + END{print a " ‡ " b " ‡ " t}')" ;; "exaile"*) song="$(dbus-send --print-reply --dest=org.exaile.Exaile /org/exaile/Exaile \ org.exaile.Exaile.Query | - awk -F':|,' '{if ($6 && $8 && $4) printf $6 " -" $8 " -" $4}')" + awk -F':|,' '{if ($6 && $8 && $4) printf $6 " ‡" $8 " ‡" $4}')" ;; "quodlibet"*) song="$(dbus-send --print-reply --dest=net.sacredchao.QuodLibet \ /net/sacredchao/QuodLibet net.sacredchao.QuodLibet.CurrentSong |\ awk -F'"' '/artist/ {getline; a=$2} /album/ {getline; b=$2} - /title/ {getline; t=$2} END{print a " - " b " - " t}')" + /title/ {getline; t=$2} END{print a " ‡ " b " ‡ " t}')" ;; "pogo"*) song="$(dbus-send --print-reply --dest=org.mpris.pogo /Player \ org.freedesktop.MediaPlayer.GetMetadata | awk -F'"' '/string "artist"/ {getline; a=$2} /string "album"/ {getline; b=$2} \ - /string "title"/ {getline; t=$2} END{print a " - " b " - " t}')" + /string "title"/ {getline; t=$2} END{print a " ‡ " b " ‡ " t}')" ;; - *) mpc >/dev/null 2>&1 && song="$(mpc -f '%artist% - %album% - %title%' current)" ;; + *) mpc >/dev/null 2>&1 && song="$(mpc -f '%artist% ‡ %album% ‡ %title%' current)" ;; esac - # TODO: adjust for album: "$(trim "$song")" == "- -" - [[ "$(trim "$song")" == "-" ]] && unset -v song + [[ "$song" != *[a-z]* ]] && unset -v song # Display Artist, Album and Title on separate lines. if [[ "$song_shorthand" == "on" && "$song" ]]; then - artist="${song/ -*}" - album="${song#*- }" - album="${album% -*}" - song="${song/*-}" + artist="${song/ ‡*}" + album="${song#*‡ }" + album="${album% ‡*}" + song="${song/*‡}" - if [[ "$song" != "$artist" ]]; then - prin "Artist" "$artist" - prin "Album" "$album" - prin "Song" "$song" - else - prin "$subtitle" "$song" - fi + [[ "$(trim "$artist")" ]] && prin "Artist" "$artist" + [[ "$(trim "$album")" ]] && prin "Album" "$album" + [[ "$(trim "$song")" ]] && prin "Song" "$song" fi } From cfcd6fff17d1457099685c800f12132b679b0596 Mon Sep 17 00:00:00 2001 From: Dylan Araps Date: Wed, 9 May 2018 18:28:17 +1000 Subject: [PATCH 7/9] song: Fix separator when printed. --- neofetch | 2 ++ 1 file changed, 2 insertions(+) diff --git a/neofetch b/neofetch index aa9975a1..c9150cfd 100755 --- a/neofetch +++ b/neofetch @@ -1530,6 +1530,8 @@ guayadeque|yarock|qmmp|quodlibet|deepin-music|tomahawk|pogo|elisa/ {printf $5 " [[ "$(trim "$album")" ]] && prin "Album" "$album" [[ "$(trim "$song")" ]] && prin "Song" "$song" fi + + song="${song//‡/-}" } get_resolution() { From b6f0460b3581ec7a259c70d2875c4201ab46ebf2 Mon Sep 17 00:00:00 2001 From: Dylan Araps Date: Wed, 9 May 2018 21:23:10 +1000 Subject: [PATCH 8/9] song: Better splitting. --- neofetch | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/neofetch b/neofetch index 0189a1a0..29cbab24 100755 --- a/neofetch +++ b/neofetch @@ -2490,10 +2490,7 @@ get_song() { # Display Artist, Album and Title on separate lines. if [[ "$song_shorthand" == "on" && "$song" ]]; then - artist="${song/ ‡*}" - album="${song#*‡ }" - album="${album% ‡*}" - song="${song/*‡}" + LC_ALL="$sys_locale" IFS="‡" read -r artist album song <<< "$song" [[ "$(trim "$artist")" ]] && prin "Artist" "$artist" [[ "$(trim "$album")" ]] && prin "Album" "$album" From ccced8d99731fde8efed30ea08817583e03aaae9 Mon Sep 17 00:00:00 2001 From: Michael Straube Date: Wed, 9 May 2018 15:52:51 +0200 Subject: [PATCH 9/9] song: fix audacious album fallback to get_song_dbus() when song_shorthand is on audtool won't work due to the '-' separator in it's output --- neofetch | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/neofetch b/neofetch index 29cbab24..7742e91d 100755 --- a/neofetch +++ b/neofetch @@ -2417,7 +2417,7 @@ get_song() { "audacious"*) song="$(audtool current-song)" - [[ -z "$song" ]] && get_song_dbus "audacious" + [[ -z "$song" || "$song_shorthand" == "on" ]] && get_song_dbus "audacious" ;; "cmus"*)