Merge pull request #1151 from dylanaraps/song_fix5

song: Fix various issues
This commit is contained in:
Dylan Araps 2019-01-07 17:14:57 +02:00 committed by GitHub
commit e213ee7e58
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 21 additions and 14 deletions

View File

@ -76,6 +76,7 @@ print_info() {
# info "Battery" battery # info "Battery" battery
# info "Font" font # info "Font" font
# info "Song" song # info "Song" song
# [[ $player ]] && prin "Music Player" "$player"
# info "Local IP" local_ip # info "Local IP" local_ip
# info "Public IP" public_ip # info "Public IP" public_ip
# info "Users" users # info "Users" users
@ -429,7 +430,6 @@ disk_subtitle="mount"
# exaile # exaile
# gnome-music # gnome-music
# gmusicbrowser # gmusicbrowser
# Google Play
# guayadeque # guayadeque
# iTunes # iTunes
# juk # juk
@ -437,6 +437,7 @@ disk_subtitle="mount"
# mocp # mocp
# mopidy # mopidy
# mpd # mpd
# netease-cloud-music
# pogo # pogo
# pragha # pragha
# qmmp # qmmp
@ -2339,7 +2340,6 @@ get_song() {
"exaile" "exaile"
"gnome-music" "gnome-music"
"gmusicbrowser" "gmusicbrowser"
"Google Play"
"guayadeque" "guayadeque"
"iTunes" "iTunes"
"juk" "juk"
@ -2347,6 +2347,7 @@ get_song() {
"mocp" "mocp"
"mopidy" "mopidy"
"mpd" "mpd"
"netease-cloud-music"
"pogo" "pogo"
"pragha" "pragha"
"qmmp" "qmmp"
@ -2384,10 +2385,9 @@ get_song() {
case "${player/*\/}" in case "${player/*\/}" in
"mpd"*|"mopidy"*) song="$(mpc -f '%artist%\n%album%\n%title%' current "${mpc_args[@]}")" ;; "mpd"*|"mopidy"*) song="$(mpc -f '%artist%\n%album%\n%title%' current "${mpc_args[@]}")" ;;
"mocp"*) song="$(mocp -Q '%artist\n%album\n%song')" ;; "mocp"*) song="$(mocp -Q '%artist\n%album\n%song')" ;;
"google play"*) song="$(gpmdp-remote current)" ;; "deadbeef"*) song="$(deadbeef --nowplaying-tf '%artist%\\n%album%\\n%title%')" ;;
"deadbeef"*) song="$(deadbeef --nowplaying-tf '%artist%\n%album%\n%title%')" ;;
"xmms2d"*) song="$(xmms2 current -f "\${artist}"$'\n'"\${album}"$'\n'"\${title}")" ;; "xmms2d"*) song="$(xmms2 current -f "\${artist}"$'\n'"\${album}"$'\n'"\${title}")" ;;
"qmmp"*) song="$(qmmp --nowplaying '%p\n%a\n%t')" ;; "qmmp"*) song="$(qmmp --nowplaying '%p\\n%a\\n%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" ;;
@ -2407,6 +2407,7 @@ get_song() {
"dragon"*) get_song_dbus "dragonplayer" ;; "dragon"*) get_song_dbus "dragonplayer" ;;
"smplayer"*) get_song_dbus "smplayer" ;; "smplayer"*) get_song_dbus "smplayer" ;;
"rhythmbox"*) get_song_dbus "rhythmbox" ;; "rhythmbox"*) get_song_dbus "rhythmbox" ;;
"netease-cloud-music"*) get_song_dbus "netease-cloud-music" ;;
"cmus"*) "cmus"*)
song="$(cmus-remote -Q | awk 'BEGIN { ORS=" "}; song="$(cmus-remote -Q | awk 'BEGIN { ORS=" "};
@ -2467,22 +2468,28 @@ get_song() {
/"title"/ {t=$4} END {print a "\n" b "\n" t}')" /"title"/ {t=$4} END {print a "\n" b "\n" t}')"
;; ;;
*) mpc &>/dev/null && song="$(mpc -f '%artist%\n%album%\n%title%' current)" ;; *) mpc &>/dev/null && song="$(mpc -f '%artist%\n%album%\n%title%' current)" || return ;;
esac esac
[[ "$song" != *[a-z]* ]] && { unset -v song; return; } IFS=$'\n' read -d "" -r artist album title <<< "${song//'\n'/$'\n'}"
IFS=$'\n' read -d "" -r artist album title <<< "$song" # Make sure empty tags are truly empty.
artist="$(trim "$artist")"
album="$(trim "$album")"
title="$(trim "$title")"
# Set default values if no tags were found.
: "${artist:=Unknown Artist}" "${album:=Unknown Album}" "${title:=Unknown Song}"
# 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
[[ "$(trim "$artist")" ]] && prin "Artist" "$artist" prin "Artist" "$artist"
[[ "$(trim "$album")" ]] && prin "Album" "$album" prin "Album" "$album"
[[ "$(trim "$song")" ]] && prin "Song" "$title" prin "Song" "$title"
else else
song="${song_format/\%artist\%/${artist}}" song="${song_format/\%artist\%/$artist}"
song="${song/\%album\%/${album}}" song="${song/\%album\%/$album}"
song="${song/\%title\%/${title}}" song="${song/\%title\%/$title}"
fi fi
} }