X-Git-Url: https://jasonwoof.com/gitweb/?a=blobdiff_plain;f=baraction.sh;h=b81ceee28ba4a1750498b291b0a9c865ae37bbda;hb=6d08df47448f7f544d1814df558057cc45e845bd;hp=d7bd57111660fa60389ac32682f25be82a7da41f;hpb=5f373c8f32f2b1d32f61c4029f4f5c19c60fe7d4;p=spectrwm.git diff --git a/baraction.sh b/baraction.sh index d7bd571..b81ceee 100644 --- a/baraction.sh +++ b/baraction.sh @@ -1,2 +1,53 @@ #!/bin/sh -while :; do echo "battery" `apm -l` "%"; sleep 59; done + +print_cpu() { + echo -n "CPU: ${7}% User ${8}% Nice ${9}% Sys ${10}% Int ${11}% Idle " +} + +print_apm() { + BAT_STATUS=$1 + BAT_LEVEL=$2 + AC_STATUS=$3 + + if [ $AC_STATUS -ne 255 -o $BAT_STATUS -lt 4 ]; then + if [ $AC_STATUS -eq 0 ]; then + echo -n "on battery (${BAT_LEVEL}%)" + else + case $AC_STATUS in + 1) + AC_STRING="on AC: " + ;; + 2) + AC_STRING="on backup AC: " + ;; + *) + AC_STRING="" + ;; + esac; + case $BAT_STATUS in + 4) + BAT_STRING="(no battery)" + ;; + [0-3]) + BAT_STRING="(battery ${BAT_LEVEL}%)" + ;; + *) + BAT_STRING="(battery unknown)" + ;; + esac; + + FULL="${AC_STRING}${BAT_STRING}" + if [ "$FULL" != "" ]; then + echo -n "$FULL" + fi + fi + fi +} + +while :; do + # you probably want to reduce the sleep below if you enable this + #print_cpu `/usr/sbin/iostat -C` + print_apm `/usr/sbin/apm -alb` + echo "" + sleep 59 +done