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


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

I use this code in gnu screen's statusbar:

backtick 1 1 1 sh -c 'perl -ne "/^(la|re|st)[^:]+:\s+(\S+)\s/and \$h{\ +$1}=\$2}{\$h{st}=~s/of.*/-/;\$h{st}=~s/on.*/+/;printfq(%.0f%%%s),\$h{ +re}*100/\$h{la},\$h{st}" /proc/acpi/battery/BAT0/* /proc/acpi/ac_adap +ter/ACAD/state'