Thursday, 1 July 2010

Ubuntu (10.04) custom power button event

Update 14. Oct. 2010: Works in Ubuntu 10.10 as well.

To poweroff only if the power button is pressed twice - change /etc/acpi/ like this:

# /etc/acpi/
# Initiates a shutdown when the power putton has been
# pressed.
# you need to double 'click' the power button to shutdown
( if ! [ $(pidof -x | wc -w) -eq 3 ]; then
        sleep .4
fi) &

It won't ask silly questions either - just shutdown now.
Now remove the wire from the reset button to make it more kid proof.