Create an extremely simple battery monitor for dzen2.

I have this really simple bash/dzen2 script I’d like to share. It basically displays how much battery there is left as a dzen2 bar.

So here is the script:

# A very simple battery monitor script.
current=`grep remaining /proc/acpi/battery/BAT0/state | awk {'print $3'}`
full=`grep full /proc/acpi/battery/BAT0/info | awk {'print $4'}`
percent=`echo "($current*100)/$full" | bc`
echo $percent | gdbar -ss 1 -h 10 -w 90 -fg 'orange' -bg '#222222' | dzen2 -p 3 -w 90 -h 10 -x 1188 -y 18

I have placed this script in ~/bin and bound it to +b in my xmonad.hs.

Here is how it looks:

Leave a Reply