/etc/acpi/battery.pl
This creates a file with the time we went on battery.
Now how is this called by acpi? I modified /etc/acpi/power.sh to call this script right after the includes.
Now how is this called by acpi? I modified /etc/acpi/power.sh to call this script right after the includes.
#!/usr/bin/perl
warn "On Battery [$ARGV[0]\n";
my $status = `/usr/bin/acpi -Ba`;
#AC Adapter 1: on-line
my $stat_file = '/var/run/battery_status';
if ($status =~m/on-line/i){
warn "On AC\n";
unlink ($stat_file) if (-e $stat_file);
}else{
warn "On Battery\n";
open (FH, ">$stat_file") or die "Couldn't open battery status file [$stat_file] : $!";
print FH time(),"\n";
}
