Re: [dwm] displaying things in the statusbar

From: A.S. Bradbury <asbradbury_AT_tekcentral.org>
Date: Sat, 17 Mar 2007 09:50:37 +0000

On 3/17/07, Tube <tube_AT_count0.net> wrote:
> hi there,
>
> for anyone who might be interested - here is some code for displaying
> the remaining capacity for notebook users in the statusbar:
>
> export CAPACITY=`awk '/last/ { sum += $4 } END { print sum }' /proc/acpi/battery/BAT*/info`
> while true
> do
> echo `awk '/remaining/ { sum += $3 } END { print int (sum * 100 / ENVIRON["CAPACITY"] + .5) "%" }' /proc/acpi/battery/BAT*/state` `/bin/date '+%x %H:%M:%S'` `uptime | sed 's/.*://; s/,//g'`
> sleep 1
> done | dwm
>
> that considers even serveral rechargeable batteries. so, my question is:
> has anybody maybe a more efficient or more elegant way of displaying
> that?

This code doesn't work for if the battery is not present. It would
also seem useful to represent whether the battery is charging,
discharging or at full capacity by prepending the percentage with ^, v
or =, but this is personal taste. I was just about to set up this sort
of output, planning to just take the ruby battery info parsing code
from Mauricio Fernandez's wmii-ruby.

Alex
Received on Sat Mar 17 2007 - 10:50:39 UTC

This archive was generated by hypermail 2.2.0 : Sun Jul 13 2008 - 14:39:25 UTC