"New" Idea: maybe belongs in programming forum...
Alright, I've got this idea that really only applies to laptops (I believe).
AND, in particular to laptops like my old Dell Inspiron 6400 with a battery that will power the machine for a few (like 5) minutes, at most.
(BTW, openSUSE 11.4 Xfce, not that it matters.)
In /etc/inittab there are the following lines:
pf::powerwait:/etc/init.d/powerfail start
pn::powerfailnow:/etc/init.d/powerfail now
I know these are there to allow UPS software to tell init to do a shutdown if and when the power fails. How does that work? What triggers these events?
What I'd like is for the pf: line to get kicked if the AC power fails, giving the machine time to shutdown gracefully.
Does anyone know how to write something that does that? Alternatively, of course, a script could just execute shutdown (provided it had enough privilege.) So, really, the question is, how do I find out if we're running on AC, or get a poke when that ceases to be the case?
What I'm envisioning is a bash/perl/python script or C program that runs as a daemon, gets the signal from APM or ACPI and either uses inittab or not to shut the machine down.
Any pointers would be greatly appreciated. Thanks!