Since I upgraded the firmware of my Acer Aspire One 110, I’ve noticed some little problems with the 6 cells battery: the laptop switches off when about one hour of battery time is left.
Well, it’s not really switch off but like it hangs: the power light it’s on, and the side cooler is working, and I have to press the power button for some seconds to stop it.
I did some research and tests, and these are the results:
$ cat /proc/acpi/battery/BAT1/info present: yes design capacity: 7200 mAh last full capacity: 6610 mAh battery technology: rechargeable design voltage: 11100 mV design capacity warning: 300 mAh design capacity low: 264 mAh capacity granularity 1: 32 mAh capacity granularity 2: 32 mAh model number: UM08A73 serial number: 096D battery type: LION OEM info: SIMPLO $ cat /proc/acpi/battery/BAT1/state present: yes capacity state: ok charging state: discharging present rate: 824 mA remaining capacity: 6569 mAh present voltage: 12232 mV
The remaining capacity (green) it’s the actual battery charge, and the design capacity warning (yellow) and the design capacity low (red) are the values I assume ACPI and the battery applet are checking to calculate the remaining battery charge:
$ acpi Battery 0: Discharging, 97%, 08:41:40 remaining
I don’t know if I’m getting it wrong, but it makes sense to me (and that 08:41:40 remaining is obviously wrong). The netbook freezes when the charge reaches 19% (aprox).
I guess the battery is advertising wrong values, and because the applet uses time as factor, I can’t adjust it properly.
So I programmed a Perl script to run by cron every minute, to check the battery charge value instead of the time:
#!/usr/bin/perl
use strict;
use warnings;
# empirical fix
my $fix = 1200;
sub getData
{
my $file = shift;
open(FD, '<', $file) or
die('failed to open: ' .$file);
my @lines = <FD>;
close(FD);
my %data;
foreach(@lines)
{
chomp;
s/\s+//g;
s/mAh//g;
my ($key, $value) = split(':');
$data{$key} = $value;
}
return %data;
}
my %state = getData('/proc/acpi/battery/BAT1/state');
exit 0 unless $state{'chargingstate'} eq 'discharging';
my %info = getData('/proc/acpi/battery/BAT1/info');
if($state{'remainingcapacity'} <= $info{'designcapacitywarning'} + $fix)
{
system('aplay alarm.wav');
}
if($state{'remainingcapacity'} <= $info{'designcapacitywarning'} + $fix - 100)
{
system('sudo /sbin/halt -p');
}
exit 0;
# EOF
Please, keep into account that this is a hack. After some tests, I’ve found that adding 1200 to design capacity warning it’s a good fix.
When the limit is reached, I play an alarm sound, until I call halt to switch off the netbook as cleanly as possible (notice that I’ve configured sudo to let my user run halt without password).
With this little workaround, everything in my LXDE based Fedora 13 fit my needs!
