#!/bin/bash
# bat - display remaining battery capacity in percent 
# Done 2007 by Jonas Mitschang, jonen@mitschang.net
# GPL, if you improve this script, please send me a copy.

# directory of the battery status
bat=/proc/acpi/battery/BAT0

IFS=":"
echo $(( $( cat $bat/state $bat/info | while read a b; do
    if [ "$a" == "remaining capacity" ]; then
        echo -n "$b" | sed "s/[ mAh]//g"
        echo -n " * 100 / "
    fi
    if [ "$a" == "last full capacity" ]; then
        echo -n $b | sed "s/[ mAh]//g"
    fi;
done ) ))

