feat: prevent sb-music to print long strings
parse title and artist individually to prevent the final string to too long (and cut)
This commit is contained in:
parent
87e453c7a8
commit
972abb9bf7
@ -10,10 +10,15 @@
|
||||
######################################################################
|
||||
|
||||
|
||||
format() { sed "s/^volume:n\/a.*//g;/^volume:/d;s/\\&/&/g;s/\\[paused\\].*//g;s/\\[playing\\].*//g"; }
|
||||
|
||||
mpc="$(mpc --format "%albumartist% - %title%")"
|
||||
format() { tac | sed "s/^volume:n\/a.*//g;/^volume:/d;s/\\&/&/g;s/\\[paused\\].*/⏸/g;s/\\[playing\\].*/🎵/g" | paste -sd ' ' -;}
|
||||
title="$(echo "$mpc" | head -n1 | awk -F " - " '{ printf "%s", $2 }')"
|
||||
[ "$(echo "$title" | wc -c)" -gt 18 ] && title="$(printf "%.15s..." "$title")"
|
||||
artist="$(echo "$mpc" | head -n1 | awk -F " - " '{ printf "%s", $1 }')"
|
||||
[ "$(echo "$artist" | wc -c)" -gt 18 ] && artist="$(printf "%.15s..." "$artist")"
|
||||
status="$(echo "$mpc" | tail -n2 | format)"
|
||||
|
||||
pgrep -f sb-mpdup >/dev/null 2>&1 || sb-mpdup >/dev/null 2>&1 &
|
||||
|
||||
mpc=$(echo "$mpc" | format)
|
||||
[ -n "$mpc" ] && printf " %s " "$mpc"
|
||||
[ -n "$status" ] && printf " %s %s - %s " "$status" "$artist" "$title"
|
||||
|
Reference in New Issue
Block a user