Re: [ACPI-sppt] battery life perl script
"Net Llama!" <[email protected]>
| Newsgroups | gmane.linux.acpi.support |
|---|---|
| Organization | HAL-III |
| Message-ID | <[email protected]> |
I'm running 2.4.21-pre2 on my Sharp MV12W with the acpi support that is
in that mainline kernel. I've got some odd contents under
/proc/acpi/battery:
# ls -l
total 0
dr-xr-xr-x 2 root root 0 Jul 4 22:23 0
dr-xr-xr-x 2 root root 0 Jul 4 22:23 0
Inside of one of them, there's a info and status file, and both have:
Present: no
Any ideas what might be going on here?
On 07/04/03 10:28, Emma Jane Hogbin wrote:
> 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";
>
>
>
--
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
L. Friedman [email protected]
Linux Step-by-step & TyGeMo: http://netllama.ipfox.com
10:20pm up 6 days, 6:45, 1 user, load average: 0.22, 0.18, 0.18
-------------------------------------------------------
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