Shutdown Pressing Power Button
If you want to shutdown your system by simply pressing the power button, do the following:
- Install the acpid package.
- If there is no hal in the DAEMONS array in rc.conf, add acpid to the DAEMONS array.
- Create a file in /etc/acpi/events/ named power with following content:
# /etc/acpi/events/power # This is called when the user presses the power button event=button/power (PWR.||PBTN) action=/sbin/poweroff
To be able to test it, make sure the acpid daemon is started
If you do not have hal, start the acpid daemon yourself:
# /etc/rc.d/acpid start
Otherwise restart hal, it will take care of acpid:
# /etc/rc.d/hal restart
From now on, pressing the power button (lightly, not for a few seconds) should properly shutdown the system. Note that if you have hibernate configured and working you may want to change the last line with:
If you're using a more sophisticated WM, you should use its own shutdown call, so it'd save its session etc.
Change the action (in /etc/acpi/events/power) to:
action=/opt/kde/bin/dcop --all-users --all-sessions ksmserver ksmserver logout 0 2 0
As of KDE 4.4, you can still use dcop as shown above.
Alternatively, you can use PowerDevil:
- Delete (or comment out) /etc/acpi/events/power.
- Open System Settings.
- Go to Advanced>>Power Management.
- Select "Edit Profiles" and choose the current profile. (In KDE 4.4, the default profile is "Powersave.")
- Select "Shutdown" as the action for "When power button is pressed."
- Press Apply.
Todo: Add simple multi-user configuration steps.
For XFCE4.4 change the action line to:
action=echo POWEROFF | /usr/lib/xfce4/xfsm-shutdown-helper
Note: For a more robust solution (If you are facing frequent WM crashes or working on a sacrificial PC for developing or testing your software...), you should take a look at "/usr/src/linux/Documentation/sysrq.txt", which is a kernel facility for yielding you (the user...) the CPU so that it could be used for any rescue work.
Add a technique that works regardless of VM (Gnome/KDE/xcfe/openbox/etc). Copy the /etc/acpi/events/power script from Ubuntu