[ACPI-sppt] battery life perl script
Emma Jane Hogbin <[email protected]>
| Newsgroups | gmane.linux.acpi.support |
|---|---|
| Message-ID | <[email protected]> |
For anyone that wants it, here's a tiny little battery life script.
emmajane@debian:~$ /usr/bin/battery
Battery life:
Full: 3920 mAh
Current: 2680 mAh
Remaining: 68 %
#!/usr/bin/perl -w
# determine the last full size of the battery
# the current size of the battery
# the % left in the battery
my $batterydir = "/proc/acpi/battery/BAT0";
$current = `cat $batterydir/state`;
$full = `cat $batterydir/info`;
$current =~ s/(.*)remaining capacity:\s+([\d]+) (.*)/$2/gs;
$full =~ s/(.*)last full capacity:\s+([\d]+) (.*)/$2/gs;
$remain = $current / $full * 100;
$remain = sprintf("%.f", $remain);
#sprintf("%.2f", 2.454)
print "Battery life: \n";
print "Full:\t\t$full mAh\n";
print "Current:\t$current mAh\n";
print "Remaining:\t$remain %\n";
--
Emma Jane Hogbin
[[ 416 417 2868 ][ www.xtrinsic.com ]]
-------------------------------------------------------
This SF.Net email sponsored by: Free pre-built ASP.NET sites including
Data Reports, E-commerce, Portals, and Forums are available now.
Download today and enter to win an XBOX or Visual Studio .NET.
http://aspnet.click-url.com/go/psa00100006ave/direct;at.asp_061203_01/01