Hardware stuff, especially laptops is usually window\$/manufacturer specifc so getting some of it work work can be a bit of a pain. In FC1 low batteries & standby is handled by APM, in FC2 upwards APM is replaced with ACPI & this is a quick text on getting going.
There are two folders & a service :
The service , I think runs in the background monitoring the hardware, you can then put events into /etc/acpi/events and get things to happen when the deamon spots them .
I originally tested this on an HP Omnbook 6000, but now I'm using a compaq nc6000 . To replace apm I need to
- Monitor Battery / Power Status
- React when power button / standby pressed
- Do Something when the lid is closed
To get started I had a look at the documentation ;) also there is an example in FC3 ( /etc/acpi/events/sample.conf )
# This is a sample ACPID configuration event=button/power.* action=/sbin/shutdown -h now
the Documentation explains that all acpi "real time" info is stored in /proc/acpi .
If you look /proc/acpi there is a directory "button" and in there "power" , so sample.conf seems to suggest if anything under "power" changes do action (in this case shutdown the machine).
Armed with this I could "test" with something a little quicker than switching on/off the machine; like opening / closing the lid....
So, in /proc/acpi/button/lid/C139 (the C139 is laptop specific) there is a file called state, and when it will tell you if the lid is open or closed (just in case you didn't know ;) ), now it is this "lid" directory that acpi will be looking for, so what you do is create a file called /etc/acpi/events/lid and put in it
You'll notice that the action is set to /etc/acpi/actions/lid "%e" this will be a script, but you could point it to any script/executable you like. In /etc/acpi/actions/lid I have put
Now, this needs a little explaining.....
There a couple of things you need to know about acpi
- acpi runs as root, so any event get's executed with root priveleges :D
- %e is an incremental number, odd numbers for lid closed & even for lid open
- To get these changes to work you need to restart the acpi service
So as you can see my lid open/close script gets a little complicated. To play if you remove the comments in from of the "wall" commands, save an open an empty shell, when you open & close the lid you get broadcast messages from root ! :cool: or if you just leave it as it is it'll try and run "nick"'s screen saver :D
Now my old laptop had both a standby or sleep button and a power button, but getting events to happen is exactly the same, simply create a script doing what you want it to do, create a file ine /etc/acpi/events and set the event to event=button/power.* (or event=button/sleep.*) and voila !
Now finally, monitoring battery status, thankfully gnome already has a nice applet
I hope you've found this of some use !