File tree Expand file tree Collapse file tree 1 file changed +15
-9
lines changed Expand file tree Collapse file tree 1 file changed +15
-9
lines changed Original file line number Diff line number Diff line change @@ -2467,22 +2467,28 @@ get_song() {
2467
2467
/"title"/ {t=$4} END {print a "\n" b "\n" t}' ) "
2468
2468
;;
2469
2469
2470
- * ) mpc & > /dev/null && song=" $( mpc -f ' %artist%\n%album%\n%title%' current) " ;;
2470
+ * ) mpc & > /dev/null && song=" $( mpc -f ' %artist%\n%album%\n%title%' current) " || return ;;
2471
2471
esac
2472
2472
2473
- [[ " $song " != * [a-z]* ]] && { unset -v song; return ; }
2474
-
2475
2473
IFS=$' \n ' read -d " " -r artist album title <<< " $song"
2476
2474
2475
+ # Make sure empty tags are truly empty.
2476
+ artist=" $( trim " $artist " ) "
2477
+ album=" $( trim " $album " ) "
2478
+ title=" $( trim " $title " ) "
2479
+
2480
+ # Set default values if no tags were found.
2481
+ : " ${artist:= Unknown Artist} " " ${album:= Unknown Album} " " ${title:= Unknown Song} "
2482
+
2477
2483
# Display Artist, Album and Title on separate lines.
2478
2484
if [[ " $song_shorthand " == " on" ]]; then
2479
- [[ " $( trim " $artist " ) " ]] && prin " Artist" " $artist "
2480
- [[ " $( trim " $album " ) " ]] && prin " Album" " $album "
2481
- [[ " $( trim " $song " ) " ]] && prin " Song" " $title "
2485
+ prin " Artist" " $artist "
2486
+ prin " Album" " $album "
2487
+ prin " Song" " $title "
2482
2488
else
2483
- song=" ${song_format/ \% artist\% / ${ artist} } "
2484
- song=" ${song/ \% album\% / ${ album} } "
2485
- song=" ${song/ \% title\% / ${ title} } "
2489
+ song=" ${song_format/ \% artist\% / $artist } "
2490
+ song=" ${song/ \% album\% / $album } "
2491
+ song=" ${song/ \% title\% / $title } "
2486
2492
fi
2487
2493
}
2488
2494
You can’t perform that action at this time.
0 commit comments