The conversation on this page has been archived and is no longer active.

Battery capacity script

Message #1 - Posted 2005/08/18 - Ian McCall

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

Message #2 - Posted 2005/08/18 - Tim Hodgson

Ian McCall wrote:

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.

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: 5400

telling me that the capacity's dropped from 6421 to 5400? --
TimH
pull tooth to reply by email

Message #3 - Posted 2005/08/18 - Ian McCall

On 2005-08-18 14:19:40 +0100, Tim Hodgson said:

Ian McCall wrote:

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.

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: 5400

telling me that the capacity's dropped from 6421 to 5400?

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: 4400

So I've gone from 4400 to 4287.

Cheers,
Ian

Message #4 - Posted 2005/08/18 - Tim Hodgson

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

Need Help? Have a Question?

Looking for more help, comments, and answers?

Ask your questions on Ask Different. Ask Different is a community of Apple users ready to help.