song: Use ascii characters to split fields.
This commit is contained in:
parent
3ad38d7c95
commit
2a13d62c0c
1 changed files with 20 additions and 20 deletions
40
neofetch
40
neofetch
|
@ -2364,18 +2364,18 @@ get_song() {
|
||||||
org.freedesktop.DBus.Properties.Get string:'org.mpris.MediaPlayer2.Player' \
|
org.freedesktop.DBus.Properties.Get string:'org.mpris.MediaPlayer2.Player' \
|
||||||
string:'Metadata' |\
|
string:'Metadata' |\
|
||||||
awk -F '"' 'BEGIN {RS=" entry"}; /xesam:artist/ {a = $4} /xesam:album/ {b = $4}
|
awk -F '"' 'BEGIN {RS=" entry"}; /xesam:artist/ {a = $4} /xesam:album/ {b = $4}
|
||||||
/xesam:title/ {t = $4} END {print a " ‡ " b " ‡ " t}'
|
/xesam:title/ {t = $4} END {print a " -@- " b " -@- " t}'
|
||||||
)"
|
)"
|
||||||
}
|
}
|
||||||
|
|
||||||
case "${player/*\/}" in
|
case "${player/*\/}" in
|
||||||
"mpd"* | "mopidy"*) song="$(mpc -f '%artist% ‡ %album% ‡ %title%' current)" ;;
|
"mpd"* | "mopidy"*) song="$(mpc -f '%artist% -@- %album% -@- %title%' current)" ;;
|
||||||
"mocp"*) song="$(mocp -Q "%artist ‡ %album ‡ %song")" ;;
|
"mocp"*) song="$(mocp -Q "%artist -@- %album -@- %song")" ;;
|
||||||
"google play"*) song="$(gpmdp-remote current)" ;;
|
"google play"*) song="$(gpmdp-remote current)" ;;
|
||||||
"rhythmbox"*) song="$(rhythmbox-client --print-playing-format '%ta ‡ %at ‡ %tt')" ;;
|
"rhythmbox"*) song="$(rhythmbox-client --print-playing-format '%ta -@- %at -@- %tt')" ;;
|
||||||
"deadbeef"*) song="$(deadbeef --nowplaying-tf '%artist% ‡ %album% ‡ %title%')" ;;
|
"deadbeef"*) song="$(deadbeef --nowplaying-tf '%artist% -@- %album% -@- %title%')" ;;
|
||||||
"xmms2d"*) song="$(xmms2 current -f '${artist} ‡ ${album} ‡ ${title}')" ;;
|
"xmms2d"*) song="$(xmms2 current -f '${artist} -@- ${album} -@- ${title}')" ;;
|
||||||
"qmmp"*) song="$(qmmp --nowplaying '%p ‡ %a ‡ %t')" ;;
|
"qmmp"*) song="$(qmmp --nowplaying '%p -@- %a -@- %t')" ;;
|
||||||
"gnome-music"*) get_song_dbus "GnomeMusic" ;;
|
"gnome-music"*) get_song_dbus "GnomeMusic" ;;
|
||||||
"lollypop"*) get_song_dbus "Lollypop" ;;
|
"lollypop"*) get_song_dbus "Lollypop" ;;
|
||||||
"clementine"*) get_song_dbus "clementine" ;;
|
"clementine"*) get_song_dbus "clementine" ;;
|
||||||
|
@ -2395,7 +2395,7 @@ get_song() {
|
||||||
/tag artist/ {$1=$2=""; sub(" ", ""); a=$0}\
|
/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}\
|
/tag title/ {$1=$2=""; sub(" ", ""); t=$0}\
|
||||||
END { print a " ‡ " b " ‡ " t }')"
|
END { print a " -@- " b " -@- " t }')"
|
||||||
;;
|
;;
|
||||||
|
|
||||||
"spotify"*)
|
"spotify"*)
|
||||||
|
@ -2404,61 +2404,61 @@ get_song() {
|
||||||
|
|
||||||
"Mac OS X")
|
"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 & " -@- " & album of current track as¬
|
||||||
string & " ‡ " & name of current track as string')"
|
string & " -@- " & name of current track as string')"
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
;;
|
;;
|
||||||
|
|
||||||
"itunes"*)
|
"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 & " -@- " & album of current track as¬
|
||||||
string & " ‡ " & name of current track as string')"
|
string & " -@- " & name of current track as string')"
|
||||||
;;
|
;;
|
||||||
|
|
||||||
"banshee"*)
|
"banshee"*)
|
||||||
song="$(banshee --query-artist --query-album --query-title |\
|
song="$(banshee --query-artist --query-album --query-title |\
|
||||||
awk -F':' '/^artist/ {a=$2} /^album/ {b=$2} /^title/ {t=$2}
|
awk -F':' '/^artist/ {a=$2} /^album/ {b=$2} /^title/ {t=$2}
|
||||||
END{print a " ‡ " b " ‡ "t}')"
|
END{print a " -@- " b " -@- "t}')"
|
||||||
;;
|
;;
|
||||||
|
|
||||||
"amarok"*)
|
"amarok"*)
|
||||||
song="$(qdbus org.kde.amarok /Player GetMetadata |\
|
song="$(qdbus org.kde.amarok /Player GetMetadata |\
|
||||||
awk -F':' '/^artist:/ {a=$2} /^album:/ {b=$2} /^title:/ {t=$2}
|
awk -F':' '/^artist:/ {a=$2} /^album:/ {b=$2} /^title:/ {t=$2}
|
||||||
END{print a " ‡ " b " ‡ " t}')"
|
END{print a " -@- " b " -@- " t}')"
|
||||||
;;
|
;;
|
||||||
|
|
||||||
"pragha"*)
|
"pragha"*)
|
||||||
song="$(pragha -c | awk -F':' '/^artist/ {a=$2} /^album/ {b=$2} /^title/ {t=$2}
|
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"*)
|
"exaile"*)
|
||||||
song="$(dbus-send --print-reply --dest=org.exaile.Exaile /org/exaile/Exaile \
|
song="$(dbus-send --print-reply --dest=org.exaile.Exaile /org/exaile/Exaile \
|
||||||
org.exaile.Exaile.Query |
|
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"*)
|
"quodlibet"*)
|
||||||
song="$(dbus-send --print-reply --dest=net.sacredchao.QuodLibet \
|
song="$(dbus-send --print-reply --dest=net.sacredchao.QuodLibet \
|
||||||
/net/sacredchao/QuodLibet net.sacredchao.QuodLibet.CurrentSong |\
|
/net/sacredchao/QuodLibet net.sacredchao.QuodLibet.CurrentSong |\
|
||||||
awk -F'"' '/artist/ {getline; a=$2} /album/ {getline; b=$2}
|
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"*)
|
"pogo"*)
|
||||||
song="$(dbus-send --print-reply --dest=org.mpris.pogo /Player \
|
song="$(dbus-send --print-reply --dest=org.mpris.pogo /Player \
|
||||||
org.freedesktop.MediaPlayer.GetMetadata |
|
org.freedesktop.MediaPlayer.GetMetadata |
|
||||||
awk -F'"' '/string "artist"/ {getline; a=$2} /string "album"/ {getline; b=$2} \
|
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
|
esac
|
||||||
|
|
||||||
[[ "$song" != *[a-z]* ]] && { unset -v song; return; }
|
[[ "$song" != *[a-z]* ]] && { unset -v song; return; }
|
||||||
|
|
||||||
LC_ALL="$sys_locale" IFS="‡" read -r artist album title <<< "$song"
|
LC_ALL="$sys_locale" IFS=$'\n' read -d "" -r artist album title <<< "${song//-@-/$'\n'}"
|
||||||
|
|
||||||
# Display Artist, Album and Title on separate lines.
|
# Display Artist, Album and Title on separate lines.
|
||||||
if [[ "$song_shorthand" == "on" ]]; then
|
if [[ "$song_shorthand" == "on" ]]; then
|
||||||
|
|
Loading…
Reference in a new issue