dotfiles/files/dwm/dwm-status.sh

27 lines
941 B
Bash
Raw Normal View History

#!/bin/sh
xsetroot -solid black -name "starting dwm..."
#while loop to update statusbar with some goodies
while true; do
sleep 1
[ -f /tmp/$USER-screen.lock ] && continue
#memfreak to get it in MB
memfree=$(grep MemFree /proc/meminfo | awk '{ print $2 }')
memtotal=$(grep MemTotal /proc/meminfo | awk '{ print $2 }')
memfreak=$(((memtotal - memfree) / 1024))
#time
CLK=$(date +'%a %b %d %R:%S %Z')
#volume
VOL=$(amixer get Master | tail -1 | awk '{ print $5 }' | tr -d '[]')
#loadavg
AVG=$(cat /proc/loadavg | cut -d ' ' -f -3)
#network stats in Bytes
NW=$(dstat -n --nocolor 1 1 | tail -1 | awk '{ print $1, $2}')
battper=$(cat /sys/class/power_supply/BAT0/capacity)
#this one is not so good, increases a delay of 1-2s of the updating.
#put it in the xsetrootname plz (tip of the day, do not put | as first char after "
xsetroot -name "$AVG | $memfreak MB | Bat: $battper% | Vol: $VOL | $CLK |"
done