1
0
Fork 0

cleanup status bar blocks

This commit is contained in:
Luca Bilke 2022-08-07 12:54:35 +02:00
commit f355b1f6ef
5 changed files with 39 additions and 29 deletions

View file

@ -26,4 +26,4 @@ case $BLOCK_BUTTON in
6) "$TERMINAL" -e "$EDITOR" "$0" ;;
esac
date "+%d.%M.%Y $icon%H:%M"
echo " $(date "+%d.%m.%Y $icon %H:%M") "

View file

@ -1,13 +1,24 @@
#!/bin/sh
filter() { mpc | sed "/^volume:/d;s/\\&/&/g;s/\\[paused\\].*/⏸/g;/\\[playing\\].*/d;/^ERROR/Q" | paste -sd ' ' -;}
filter() {
if mpc &>/dev/null && [[ $(mpc | wc -l) -eq 3 ]]; then
song=$(mpc current -f "%artist% - %title%" | xargs -0 )
[[ $(echo $song | wc -m) -gt 37 ]] && song="${song:0:36}…"
mpc | awk 'NR==2' | grep -q playing && icon="" || icon=""
echo " $icon $song "
elif mpc &>/dev/null && [[ $(mpc | wc -l) -eq 1 ]]; then
echo " ﱙ "
else
exit 1
fi
}
pidof -x sb-mpdup >/dev/null 2>&1 || sb-mpdup >/dev/null 2>&1 &
case $BLOCK_BUTTON in
1) mpc status | filter ; setsid -f "$TERMINAL" -e ncmpcpp ;; # right click, pause/unpause
2) mpc toggle | filter ;; # right click, pause/unpause
3) mpc status | filter ; notify-send "🎵 Music module" "\- Shows mpd song playing.
3) mpc status | filter ; notify-send " Music module" "\- Shows mpd song playing.
- ⏸ when paused.
- Left click opens ncmpcpp.
- Middle click pauses.

View file

@ -6,8 +6,7 @@
case $BLOCK_BUTTON in
1) setsid -f "$TERMINAL" -e bmon ;;
3) notify-send " Network traffic module" ": Traffic received
祝: Traffic transmitted" ;;
3) notify-send "歷 Network traffic module" ": Traffic received : Traffic transmitted" ;;
6) "$TERMINAL" -e "$EDITOR" "$0" ;;
esac
@ -17,7 +16,7 @@ update() {
read -r i < "$arg"
sum=$(( sum + i ))
done
cache=${XDG_CACHE_HOME:-$HOME/.cache}/${1##*/}
cache=/tmp/${1##*/}
[ -f "$cache" ] && read -r old < "$cache" || old=0
printf %d\\n "$sum" > "$cache"
printf %d\\n $(( sum - old ))
@ -26,4 +25,4 @@ update() {
rx=$(update /sys/class/net/[ew]*/statistics/rx_bytes)
tx=$(update /sys/class/net/[ew]*/statistics/tx_bytes)
printf " %4sB 祝 %4sB\\n" $(numfmt --to=iec $rx) $(numfmt --to=iec $tx)
printf "  %4sB  %4sB \\n" $(numfmt --to=iec $rx $tx)

View file

@ -18,13 +18,13 @@ esac
vol="$(pamixer --get-volume)"
if [ "$vol" -gt "70" ]; then
icon=""
icon=""
elif [ "$vol" -gt "30" ]; then
icon="奔"
icon=""
elif [ "$vol" -gt "0" ]; then
icon=""
icon=""
else
echo " "&& exit
echo " "&& exit
fi
echo " $icon $vol% "