Software Release: battery_status.py
Tuesday, August 21st, 2007Annoyed that Fedora 7 doesn’t have the same CLI tools to get battery status, I coded up a little python script last night to do just that. It was a pretty straight-forward project that took me about an hour, but I was pretty happy with the end result. It reads the proper files out of the /proc/acpi/battery hierarchy, does some calculations on that data and the gives you what you really want.
You start with this:
thesis|18:46|~% cat /proc/acpi/battery/BAT0/info present: yes design capacity: 65520 mWh last full capacity: 69150 mWh battery technology: rechargeable design voltage: 14400 mV design capacity warning: 3457 mWh design capacity low: 200 mWh capacity granularity 1: 1 mWh capacity granularity 2: 1 mWh model number: 42T5229 serial number: 35751 battery type: LION OEM info: SANYO thesis|18:46|~% cat /proc/acpi/battery/BAT0/state present: yes capacity state: ok charging state: charging present rate: 8595 mW remaining capacity: 66620 mWh present voltage: 16690 mV
And you get this:
Battery 0: 96.46% (0:17 until charged)
In the spirit of sharing and trying new things, I thought I would register it as Google Code project and give it away under a BSD License. It was about a ten minutes process, start to finish and now the world can have it:
http://code.google.com/p/batterystatus/
Hurray for non-scarce economics!





