working with laptop battery

Daniel Dalton d.dalton at iinet.net.au
Thu Feb 18 12:11:51 CET 2010


I'm not sure I have those files, but I'll look a little harder this
weekend when I put together the script. 

Thanks for your help, 
Dan

On Sat, Feb 13, 2010 at 08:23:28PM -0600, Tim Chase wrote:
> Daniel Dalton wrote:
> >On Sat, Feb 13, 2010 at 05:26:02PM -0800, Chris Rebert wrote:
> >>It's probably gonna depend on which OS you're running. Which would be...?
> >
> >Sorry, forgot to mention this. I'm running debian linux.
> 
> 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 at rubbish:/proc/acpi/battery/BAT0$ cat alarm
> alarm:                   unsupported
> tim at 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 at 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
> 



More information about the Python-list mailing list