http://www.perlmonks.org?node_id=918671


in reply to Re^2: Laptop Battery Percentage
in thread Laptop Battery Percentage

But what if you have two batteries? Some laptops allow that. You will have multiple lines.
Information doesn't want to be free. It wants to be feline.

Replies are listed 'Best First'.
Re^4: Laptop Battery Percentage
by Tux (Canon) on Aug 05, 2011 at 07:16 UTC

    Accumulate? Untested concept:

    $ perl -MDP -e'while(<>){/^(.*)\s+capacity:\s*((\d+).*)/||next;$i{$1}[ +0]+=$2;$i{$1}[1]//=$3}print"$_: $i{$_}[0], "for keys%i;printf"%5.1f%% +\n",100*$i{remaining}[1]/$i{design}[1]' /proc/acpi/battery/*/*

    Enjoy, Have FUN! H.Merijn