I'm constantly working in the command line and need to write a program
to give me alerts on my battery. Can someone please tell me what module
I should use to access battery information? Looking for something that
perhaps makes use of acpi so I can get estimated time left as well as a
percentage.
Thanks very much for any help,
Dan
It's probably gonna depend on which OS you're running. Which would be...?
Cheers,
Chris
--
http://blog.rebertia.com
Sorry, forgot to mention this. I'm running debian linux.
Thanks,
Dan
I don't know about python modules but have a look at
/proc/acpi/battery/BAT0/info
/proc/acpi/battery/BAT0/state
You can parse the numbers you want from there.
HTH,
Daniel
--
Psss, psss, put it down! - http://www.cafepress.com/putitdown
You should be able to read/poll the various files in
/proc/acpi/battery/BAT*/*
for whatever battery information you need. Each BAT* directory
contains information about one of the batteries in the system
(it's possible, albeit rare, to have more than one). So you
might have some script that runs every $INTERVAL that looks
something like
from glob import glob
for fname in glob('/proc/acpi/battery/BAT*/*'):
f = file(fname)
for line in f:
do_something(line)
f.close()
On my Debian laptop (Gateway Solo 1200, OEM battery circa 2001),
the contents look something like
tim@rubbish:/proc/acpi/battery/BAT0$ cat alarm
alarm: unsupported
tim@rubbish:/proc/acpi/battery/BAT0$ cat info
present: yes
design capacity: 4016 mAh
last full capacity: 4011 mAh
battery technology: rechargeable
design voltage: 9600 mV
design capacity warning: 602 mAh
design capacity low: 401 mAh
capacity granularity 1: 201 mAh
capacity granularity 2: 3409 mAh
model number: QT08
serial number: SANYOQT08
battery type: NiMH
OEM info: SANYO
tim@rubbish:/proc/acpi/battery/BAT0$ cat state
present: yes
capacity state: ok
charging state: charged
present rate: unknown
remaining capacity: 4011 mAh
present voltage: 9600 mV
-tkc
Thanks for that code, I'll try putting something together this weekend.
Dan
Thanks for your help,
Dan
Had a quick look, but that path doesn't seem to exist, I'll look harder
on the weekend when I put the script together, because it has to be
somewhere.
Thanks,
Dan