#!/bin/sh #based on http://bbs.archlinux.org/viewtopic.php?id=1809 rate=`grep 'present rate' /proc/acpi/battery/BAT0/state | tr -d -c 0-9` current=`grep 'remaining capacity' /proc/acpi/battery/BAT0/state | tr -d -c 0-9` total=`grep 'last full capacity' /proc/acpi/battery/BAT0/info | tr -d -c 0-9` percent=`echo "100 * $current / $total" | bc` speed=`grep -m1 -o 'cpu MHz.*\.' /proc/cpuinfo | tr -d -c '\n0-9'` if grep -q discharging /proc/acpi/battery/BAT0/state then minutes=`echo "60 * $current / $rate" | bc` echo $speed $minutes $percent'%' else echo $speed $percent'%' fi