How do I modify the options for the power button?

When I press the power button a dialog opens, but I want to shutdown the system without receiving "Do you really really want to shutdown?". How can I choose a direct shutdown action on a pressed power button?

I had the same problem with the 11.04 version, but I don't remember the solution and yesterday I upgraded to Ubuntu 11.10.


Solution 1:

Lid Close Action

To set up the Laptop Lid Close Action you have to install Advanced Setting (or the Gnome Tweak Tool). It is in the USC (Ubuntu Software Center) under either tweak or Advanced Settings. If installed press the super button and type in tweak or advanced and choose the Advanced Settings. When it opens choose the shell tab;

Advanced Settings Before

Press the arrows and choose you desired on both on AC and on battery;

Advanced Setting After

Default buttons behavior

Install dconf-tools:

sudo apt-get install dconf-tools

Press alt+f2 and open dconf-editor (or in a terminal type dconf-editor)

Navigate to org.gnome.settings-daemon.plugins.power and set your default button-power action there:

enter image description here

On some systems you will also need to mark the item suppress-logout-restart-shutdown.

Solution 2:

I'm afraid that the first answers didn't work for me, I think that the 'graphical solutions' only work for the upper right indicator, not for the power button. rulet solution works for me, I think I can improve it and make the prompt completely disappear. Instead of creating a new file you can use existing /etc/acpi/events/powerbtn file

sudo -H gedit /etc/acpi/events/powerbtn

Add # to comment line:

#action=/etc/acpi/powerbtn.sh

Add a new line:

action=/sbin/poweroff

Save file. Open a console and type:

sudo acpid restart

That works for me AND the prompt has gone, just like in ubuntu 11.04. Wish this helps.

Solution 3:

This is the quick, simple answer I needed:

gsettings set org.gnome.settings-daemon.plugins.power button-power 'hibernate'

If you want to see your settings first, try this:

gsettings get org.gnome.settings-daemon.plugins.power button-power

Or maybe this if you want to see all the power settings:

gsettings list-recursively org.gnome.settings-daemon.plugins.power