status.sh (729B)
1 #!/bin/bash 2 3 # simple statusbar script for dwm 4 5 mpc_state() { 6 if mpc | grep -q 'paused'; then 7 echo "PAUSED" 8 fi 9 if mpc | grep -q 'playing'; then 10 echo "PLAYING" 11 fi 12 } 13 14 while true; do 15 date="$(date +%y-%m-%d)" 16 time="$(date +%H:%M)" 17 bat="$(cat /sys/class/power_supply/BAT0/capacity)" 18 ram="$(LANG=C free -m | grep Mem | awk '{usage=($3/$2)*100} END {print usage "%"}')" 19 cpu="$(grep 'cpu ' /proc/stat | awk '{usage=($2+$4)*100/($2+$4+$5)} END {print usage "%"}')" 20 song="$(mpc current)" 21 mpc="$(mpc_state)" 22 temp="$(sensors | grep CPU | awk '{print $2}')" 23 fan="$(cat /proc/acpi/ibm/fan | grep 'speed:' | awk '{print $2}')" 24 25 xsetroot -name "$time | $date | BAT: $bat%; [$mpc] $song ;TEMP: $temp | FAN: $fan " 26 sleep 1 27 done