Battery capacity script
-
Ian McCall - 18 August 2005
Useful Perl script half-inched from a Slashdot discussion. It tells you various bits of battery information, most usefully the original max capacity and the current capacity, giving an indication of how far your battery has degraded.
#!/usr/bin/perl
my $info = `/usr/sbin/ioreg -p IODeviceTree -n "battery" -w 0`; my $batteryinfo = $info;
$batteryinfo =~ s/\n//g;
$batteryinfo =~ s/^.*\"(IOBatteryInfo)\" = \(\{(.*)\}\).*$/$1\n$2/g; $batteryinfo =~ s/\"([\w ]*)\"=/\t$1: /g; $batteryinfo =~ s/,/\n/g;
print $batteryinfo . "\n\n";And credit where credit is due, the original post can be found here: http://ask.slashdot.org/comments.pl?sid=159347&cid=13346381
Cheers,
Ian -
Tim Hodgson - 18 August 2005
Thanks Ian. Not sure I understand it though! Is this:
IOBatteryInfo
Capacity: 10000
Amperage: 0
Cycle Count: 143
Current: 0
Voltage: 0
Flags: 754974849
AbsoluteMaxCapacity: 5400}
{ Capacity: 6421
Amperage: 0
Cycle Count: 143
Current: 6421
Voltage: 12446
Flags: 754974725
AbsoluteMaxCapacity: 5400telling me that the capacity's dropped from 6421 to 5400?
TimH
pull tooth to reply by email -
Ian McCall - 18 August 2005
Err...yes. Now is the time to patent your battery as you've clearly found a machine that beats even perpetual motion.
On mine, I get the following output:
IOBatteryInfo:
Capacity: 4287
Amperage: 0
Cycle Count: 242
Current: 4170
Voltage: 12530
Flags: 838860805
AbsoluteMaxCapacity: 4400So I've gone from 4400 to 4287.
Cheers,
Ian -
Tim Hodgson - 18 August 2005
Ian McCall wrote:
Err...yes. Now is the time to patent your battery as you've clearly found a machine that beats even perpetual motion.
Well, they did say it was high capacity :)
Actually I wonder whether the fact that it's higher capacity (7200mAh) than the original (5400mAh I think) is confusing the script. --
TimH
pull tooth to reply by email
Download Power Manager and start saving.