Simple dwm bar script with variable timing and signalling in posix
Simple bar script for dwm and other window managers.
Inspired by dwmblocks. Written in posix.
update_cpu () {
cpu="$( grep -o "^[^ ]*" /proc/loadavg )"
}
display () {
xsetroot -name " [$weather] [$memory $cpu] [$bat] [$backlight] [$vol] $time "
}
You can use printf instead of xsetroot to feed it into some other bar like lemonbar.
trap "update_cpu;display" "RTMIN+6"
kill -40 "$(cat ~/.cache/pidofbar)"
{XF86AudioRaiseVolume,XF86AudioLowerVolume}
pulsemixer --change-volume {+,-}5 ; \
kill -34 "$(cat ~/.cache/pidofbar)"
[ $((sec % 60)) -eq 2 ] && update_cpu
To update item ever 60 seconds with an offset of 2 seconds.