How to Set Power Button to ‘shutdown -h now’ Instead of Graphical Shutdown Menu

11.10shortcut-keys

I would like to specify that when I press the power button in my laptop, a 'shutdown -h now' command is sent, instead of bringing up the graphical shutdown menu. How can I do that on Ubuntu 11.10?

Best Answer

That's simple enough. When you press the power button a ACPI event triggers the script at /etc/acpi/powerbtn.sh.

You can edit that to just run shutdown -h now as the first thing so it looks like:

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

/sbin/shutdown -h now "Power button pressed"
exit 0

# leave the old code below (in case you want to revert!)