Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

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.

share|improve this question
add comment

7 Answers 7

up vote 45 down vote accepted

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.

share|improve this answer
1  
This would be a solution... for Ubuntu 11.04. He's talking about Ubuntu 11.10. –  RobinJ Oct 15 '11 at 10:05
1  
the answer is "fixed", its not a bug, its a "feature". –  Bruno Pereira Oct 15 '11 at 10:45
    
That's better :p –  RobinJ Oct 15 '11 at 10:47
1  
I am really wondering if this means userfriendly if you need to install some app and change reg-files to make something trivial like that working. –  n3rd Nov 1 '11 at 18:57
2  
You can also use command lines for that, gsettings will do the job just fine. Its something that will be fixed soon I hope. Def not user friendly ;) –  Bruno Pereira Nov 1 '11 at 19:05
show 3 more comments

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

1.- sudo gedit /etc/acpi/events/powerbtn

2.- Add # to comment line: #action=/etc/acpi/powerbtn.sh

3.- Add a new line: action=/sbin/poweroff

4.- Save file

5.- 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.

share|improve this answer
    
Thanks I've been looking all over the place for an answer to this. All the other stuff about gsettings doesn't work for me on 12.04 with gnome shell. –  frankster Oct 23 '12 at 18:53
    
Yes! This is also the only thing that worked for me in Ubuntu 12.04. Thank you very much. –  Mark Shust Mar 31 '13 at 13:41
    
Yes, this works on Ubuntu 13.04. Other answers involving gsettings do not work (I guess, any more). –  farfareast Jun 16 '13 at 19:56
    
This worked for me on Ubuntu 12.04 but to disable the prompt I had to set button-power option in org.gnome.settings-daemon.plugins.power in dconf-editor to nothing. –  Abhinav Sarkar Jul 31 '13 at 16:26
add comment

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 list-recursively org.gnome.settings-daemon.plugins.power
share|improve this answer
    
Thanks exactly what I was looking for on Ubuntu 11.10: gsettings set org.gnome.settings-daemon.plugins.power button-power 'suspend' –  giowck Dec 3 '11 at 11:05
    
To revert this change use: gsettings set org.gnome.settings-daemon.plugins.power button-power 'interactive' –  giowck Jul 29 '13 at 9:39
add comment

Bruno's answer is only half-correct.

After installing dconf, you should navigate to apps>indicator-session

Place a check mark for the item "suppress-logout-restart-shutdown."

This will work for Unity in Ubuntu 11.10 but not for Gnome 3 or Gnome Classic.

share|improve this answer
1  
Your answer or the other answer will work in 11.10 but not Gnome3 or Classic? –  belacqua Oct 22 '11 at 2:15
    
Interestingly, I observe that this only affects the dialog popup when using the indicator in the uppper right. Pressing the power button still shows the dialog. –  Christoph Nov 21 '11 at 8:42
add comment

That didn't work for me in unity or gnome-shell(prompt was always shown). So I've used this manual

from arch linux wiki. I've created file /etc/acpi/events/power with the content:

event=button/power (PWR.||PBTN)
action=/sbin/poweroff

and executed a command:

sudo acpid restart (don't know exactly if it's right command)

And then by pressing hardware power-button computer shotdowns(the prompt will be shown, but that won't stop shutdown process).

share|improve this answer
1  
That is more helpful for headless command-line-only systems. –  BBK Aug 28 '12 at 16:02
1  
That is helpful for any type of systems. –  rulet Jan 13 '13 at 2:14
add comment

Works for Ubuntu 14

sudo apt-get install dconf-tools

Open dconf Editor

Navigate to: org => gnome => setting-deamon => plugins => power

The Holy Grail of power options is there :)

share|improve this answer
add comment

None of this worked on my 13.04 system. In the end I re-compiled gnome-session.

In gsm_shell.c and gsm_logout_dialog.c change #define AUTOMATIC_ACTION_TIMEOUT from 60 to 5

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.