sb

shitty bar for dwm
git clone git://git.ckyln.com/~cem/sb.git
Log | Files | Refs | README | LICENSE

commit c31c4eadb9888456d514a1bc757a89d72e89e8b2
parent b0dbb04baaed4b93716343dcd601486aafffa92c
Author: Cem Keylan <cem@ckyln.com>
Date:   Sat, 30 May 2020 18:19:07 +0300

showmpd: simplify function, remove usage of grep/head, etc

Diffstat:
Mfunc/sb_showmpd | 14+++++++-------
1 file changed, 7 insertions(+), 7 deletions(-)

diff --git a/func/sb_showmpd b/func/sb_showmpd @@ -1,11 +1,11 @@ # gets song info from mpd -getmpd() { - mpc -f "[[%artist% - ]%title%]|[%file%]" 2>/dev/null | grep -v "volume:" | head -n 1 | tr '\n' ' ' - mpc 2>/dev/null | awk 'NR==2' | awk '{print $3}' -} - showmpd() { - [ -z "$(getmpd)" ] && return 1 - printf "Playing: $(getmpd) $DELIMITER " + out=$(mpc -f "[[%artist% - ]%title%]|[%file%]" 2>/dev/null | tr '\n' ' ') + time="${out#*] */* }" time="${time## }" time=${time%% (*} + out=${out%% \[*} + + [ "$out" = "$time" ] && return 0 + + printf 'Playing: %s %s %s ' "$out" "$time" "$DELIMETER" }