[Debian-eeepc-devel] Hotkey events on power change

Phil Endecott spam_from_debian_eee at chezphil.org
Fri Sep 19 22:40:05 UTC 2008

Dear All,

I am investigating the ACPI events associated with power source changes.

My first observation is that the "alarm" file in 
/sys/class/power_supply/BAT0 is not functional, due to a limitation in 
the BIOS and perhaps also in the hardware.  So to implement a low 
battery alarm you need to poll the charge_now file.

Looking at the ACPI events when I connect and disconnect the power, 
there are quite a few of them.  Here's disconnecting:

battery BAT0 00000080 00000001
ac_adapter AC0 00000080 00000000
ac_adapter AC0 00000080 00000000
battery BAT0 00000080 00000001
hotkey ATKD 00000051 00000001
processor P001 00000081 00000000

"ac_adaptor ... 0" seems to be the thing to look for if you want 
something to happen when the mains goes away.  But beware: you need to 
cope with there being two events, and note that 
/sys/class/power_supply/BAT0/status is not perfectly in sync: a script 
may observe that the mains has gone but the battery is still charging!  
(Oh, and you need to agree about how to spell adapter.)

When the power comes back I see:

ac_adapter AC0 00000080 00000001
battery BAT0 00000080 00000001
hotkey ATKD 00000050 00000001
processor P001 00000081 00000000
battery BAT0 00000080 00000001
ac_adapter AC0 00000080 00000001

so "ac_adapter ... 1" indicates that the mains is back, obviously.

Finally, I let my battery run out to see what happens.  I wasn't 
expecting to get anything, but I actually saw this left in the xterm as 
the machine shut down:

hotkey ATKD 00000052 00000000
and a battery line which I foolishly didn't copy down, but was I think 
another "80 01" line.

I wasn't looking in the right direction at the time so I don't know 
exactly how long before it failed this appeared, but I think it was 
immediately prior.

The mains on/off logs also have hotkey events with codes 50 and 51 
respectively.  Do we have any document anywhere that describes what 
these various hotkey codes mean?  Perhaps these are the codes that I 
should be using.

As you can probably guess I'm putting together a low battery warning 
thing.  The other side of the problem is what should happen in response 
to the warning.  Any suggestions about this would be welcome.

Cheers, Phil.

More information about the Debian-eeepc-devel mailing list