Skip to content

Commit 8a96fd5

Browse files
committed
song: Fix issues with non-english tags
1 parent 6c966b0 commit 8a96fd5

File tree

1 file changed

+15
-9
lines changed

1 file changed

+15
-9
lines changed

neofetch

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2467,22 +2467,28 @@ get_song() {
24672467
/"title"/ {t=$4} END {print a "\n" b "\n" t}')"
24682468
;;
24692469

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 ;;
24712471
esac
24722472

2473-
[[ "$song" != *[a-z]* ]] && { unset -v song; return; }
2474-
24752473
IFS=$'\n' read -d "" -r artist album title <<< "$song"
24762474

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+
24772483
# Display Artist, Album and Title on separate lines.
24782484
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"
24822488
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}"
24862492
fi
24872493
}
24882494

0 commit comments

Comments
 (0)