Battery capacity script

It tells you various bits of battery information, most usefully the original max capacity and the current capacity
Ian McCall wrote on :

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 replied on :

Ian McCall ian@redacted.invalid 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?

Ian McCall replied on :

On 2005-08-18 14:19:40 +0100, thnews@redacted.invalid (Tim Hodgson) said:

Ian McCall ian@redacted.invalid 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

Tim Hodgson replied on :

Ian McCall ian@redacted.invalid 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.