acpi

[Bash] Remaining Battery Power as Prompt

Sven Bachmann
Hi, as seen at my pal Philipp, I also wanted to see the current battery power in the bash prompt. So here is a script which works fine on my X60s. #!/bin/bash REMAIN=`grep "remaining capacity" /proc/acpi/battery/BAT0/state | sed 's/remaining capacity:\(.*\)mWh/\1/'` FULL=`grep "last full capacity" /proc/acpi/battery/BAT0/info | sed 's/last full capacity:\(.*\)mWh/\1/'` echo $[ $REMAIN * 100 / $FULL ]`</blockquote> Just save it for example in your home directory as bat.sh and make it executable with chmod +x bat.