Friday, July 16, 2004

ACPI handling for power-button and lid-closing events

Finally have a script for handling the power-button event and
turning off the screen when the lid button is triggered. Hopefully
will soon be able to resolve the issue of suspending and hibernating
(since both are supported in my kernel, 2.6.7-gentoo-r7). For some
reason it croaks reporting some piece of hardware doesn't support the
action...still need to investigate.

Here's the perl script to place into /etc/acpi/handle.pl:

---begin----
#! /usr/bin/perl -w

use strict;

my $eventarg = shift (@ARGV);

if ($eventarg =~ /^button\/lid$/) {
system ('/usr/X11R6/bin/xset -display :0 dpms force off');
}
if($eventarg =~ /^button\/power$/) {
system('/sbin/halt');
}
---end----

Make sure that it's executable after you create it. Next step is to
update /etc/acpi/events/default:

---begin----
event=.*
action=/etc/acpi/handle.pl %e
---end----

That's it. Now you can shutdown the machine by simply pressing the
power button.

the prerequisite I didn't mention is that ACPI must be compiled into
your kernel and you must have acpid running or nothing here will work.
In the case that you need to patch your kernel to enable it check out
Mike
Hardy's Dell D800 page

No comments: