Here is mine :
awk '
$0~/remaining capacity:/ { r=$3 }
$0~/last full capacity:/ { l=$4 }
$0~/charging state:/ { status=$3 }
END {
if ( status!="charged" ) {
if ( status=="charging" ) status="|¦|"
printf("%00.01f% ",r/l*100);printf status } }
' /proc/acpi/battery/BAT0/info /proc/acpi/battery/BAT0/state
This is probably not necessary to do the command every 1 second...
On Sat, 2007-03-17 at 10:28 +0100, Tube 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?
>
> tube
Lobzang
___________________
http://lobzang.free.fr
Received on Wed Mar 21 2007 - 14:53:16 UTC
This archive was generated by hypermail 2.2.0 : Sun Jul 13 2008 - 14:39:45 UTC