Friday 22 June 2007

Power button event on gnome

On my Debian etch, I configured gnome-power-manager to ask me what to do when the power button is pressed. However, when I did, I could see the GPM prompt followed by the system immediately shutting down.

This is caused by the script /etc/acpi/powerbtn.sh, which, I believe, was written to work with KDE. I have changed mine to look like this:

#!/bin/sh
# /etc/acpi/powerbtn.sh
# Initiates a shutdown when the power putton has been
# pressed.

# If powersaved is running, let it process the acpi event
if pidof powersaved; then
exit 0
fi

# Commented-out the following line
#if ps -Af | grep -q '[k]desktop' && test -f /usr/bin/dcop

if ps -Af | grep -q 'gnome-power-manager'
then
# Commented-out the following line and added "exit 0"
# dcop --all-sessions --all-users ksmserver ksmserver logout 0 2 0 && exit 0

exit 0
else
/sbin/shutdown -h now "Power button pressed"
fi
Quick-and-dirty, but it works. Maybe I should be running powersaved but I couldn't bother.

No comments: