You are not logged in.
I'm looking for a small lightweight battery monitory for openbox to sit in my tray. If none exists, is there a file that displays the percent left so I could just cat the file and call in in the openbox pipe menu?
Thanks.
Last edited by Reasons (2008-03-23 01:42:48)
Offline
Conky have the functions needed (http://conky.sourceforge.net/variables.html look for battery)
The file is in /proc/acpi/battery/BAT? with it you can calculate the percentage using the 'last ful' from info and remaining from 'state'
acpitools provide a simple awkeable interface.
Offline
I've tried conky before and am trying to move away from it.
Offline
you can run acpi (package acpi, extra repository, i guess).
Offline
Found this script:
#!/bin/bash
current=`grep remaining /proc/acpi/battery/BAT1/state | awk {'print $3'}`
full=`grep full /proc/acpi/battery/BAT1/info | awk {'print $4'}`
percent=`echo "($current*100)/$full" | bc`
echo $percent
You need bc installed and you have to do a ls /proc/acpi/battery/ to check if your battery is a BAT0 or a BAT1.
Offline
This is one way to do it:
acpi -b | sed 's/^.*\: //g;s/%,.*/%/g'
If you just want the percentage:
acpi -b | sed 's/.*[dg], //g;s/\,.*//g'
You need "acpi" package installed for the above commands to work. If you don't want to use the acpi command for some reason:
#!/bin/sh
battery_max=`cat /proc/acpi/battery/BAT1/info | head -3 | tail -1 | sed 's/[^0-9]//g'`
battery_current=`cat /proc/acpi/battery/BAT1/state | head -5 | tail -1 | sed 's/[^0-9]//g'`
battery_level="`echo "100 * $battery_current / $battery_max" | bc`"
battery_state=`cat /proc/acpi/battery/BAT1/state | head -3 | tail -1 | sed 's/.*[[:blank:]]//g'`
if [ "${battery_state}" = "charged" ]; then
echo $battery_state;
else
echo $battery_state, $battery_level%;
fi
Offline
gbatt. that's what i used when i used flux. also may be of intrest, gvtray and gtim
edit: http://code.google.com/p/gtk-tray-utils/
Last edited by rson451 (2008-03-23 01:26:34)
archlinux - please read this and this — twice — then ask questions.
--
http://rsontech.net | http://github.com/rson
Offline
fwojciec, thanks. Really what I was looking for. Just put that into a pipe menu and it's all good.
Offline