22

I did a fresh install of Ubuntu 13.10. When I press my power button, my computer immediately shuts down. In Ubuntu 13.04 I got a nice menu, where I could choose what to do. It is gone now and I want it back. Here is my /etc/acpi/powerbtn.sh in pastebin.

I already did

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

where WORD is hibernate, power, sleep and suspend.

  • 1
    I went through my /etc/acpi/powerbtn.sh and found out that it just does nothing. The menu I’m speaking of can be summoned by the command gnome-session-quit --power-off – Wauzl Oct 21 '13 at 11:20
  • lulz. wish i'd read your comment before i went on a wild goose chase trying to find that command. – user128334 Dec 4 '13 at 4:11
  • did my answer not work for you? – user128334 Dec 5 '13 at 16:39
  • I upvoted your answer and I’m sure it would have worked; I reinstalled my whole system. I have had some other problems, too. This (oviously) fixed it for me. – Wauzl Dec 5 '13 at 20:16
  • ah, k. just saw you stopped by the site without comment so thought the notification might've been lost. strange, totally reinstalling fixed this? did you download the latest 13.10? i did a fresh install and newly had this problem. – user128334 Dec 5 '13 at 22:15
27

Check your /etc/systemd/logind.conf file. It should look like this:

[Login]
#NAutoVTs=6
#ReserveVT=6
#KillUserProcesses=no
#KillOnlyUsers=
#KillExcludeUsers=root
#Controllers=
#ResetControllers=cpu
#InhibitDelayMaxSec=5
#HandlePowerKey=poweroff
#HandleSuspendKey=suspend
#HandleHibernateKey=hibernate
#HandleLidSwitch=suspend
#PowerKeyIgnoreInhibited=no
#SuspendKeyIgnoreInhibited=no
#HibernateKeyIgnoreInhibited=no
#LidSwitchIgnoreInhibited=yes
#IdleAction=ignore
#IdleActionSec=30min

Uncomment the line that says #HandlePowerKey=poweroff and change the value to ignore.

Then restart the logind with the command: sudo restart systemd-logind or reboot your computer.

EDIT: how to create a new acpi handler Create a new file in /etc/acpi/events/. The content of the file should be:

event=<acpi_event_code>
action=<script_to_call>

where <acpi_event_code> is the code you get using the acpi_listen tool and <script_to_call> is the full path to the script you wish to call when that event happens.

They must have changed something in 13.10 because it seems that I have too few files in my /etc/accpi/events folder compared to the 13.04.

  • This does't bring back my beloved menu. It just does nothing when I press the power button now. – Wauzl Oct 21 '13 at 9:06
  • If the powerbtn.sh is actually executed whem the power button is pressed, you could try to make it execute the shutdown menu command if the X server is running and gnome is your desktop environment. Have a look at the output of the export command to determine which variables to test. If the powerbtn.sh script isn't executed at all, you could try to see which acpi event to bind to by running acpi_listen and pressing the power button. Also, perhaps there is an option in gnome to bring the power menu back, but I'm not sure as it's been a while since I last used gnome. – jeremija Oct 21 '13 at 14:01
  • I tried this and the powerbtn.sh is (probably) not executed, because nothing happens, when I press the button. The acpi_listen tells me that the button triggers an acpi event. Unfortunately my volume up and down keys don’t work either. Maybe this is related? – Wauzl Oct 21 '13 at 18:41
  • You could try the following: grep "<acpi_event_code>" /etc/acpi/events/* where <acpi_event_code> is the code of the acpi event you saw on acpi_listen. If you get a result, view that file and see the name of the script it calls. If you don't get a result, you could try adding a new file in the /etc/acpi/events/. See the edited answer for more details. – jeremija Oct 21 '13 at 19:28
  • Confirm that this works with 16.04 LTS on my mac. – Benjamin R Dec 6 '16 at 1:27
4

jeremijah put me on the right track so kudos!

I edited /etc/systemd/logind.conf as recommended, but I also did this.

1

If the above solutions don't work for you, Here is a quick work around:

  • Install xtrlock

This utility does the work for you. Though this may not answer the question, in the many solutions I'v tried (including the ones on this page) none seem to work

To install:

sudo apt install xtrlock 

To use: Type xtrlock in the command line. This will freeze mouse, keyboard

To unlock type your password and press [Enter]


It can also freeze your power button.

P.S This solution is particularly useful for those who have kids and want the power button disabled for that reason.

xtrlock - Lock X display until password supplied, leaving windows visible Source: http://manpages.ubuntu.com/manpages/artful/man1/xtrlock.1x.html

  • Please expand your answer. Is this app available in the repositories? How did you install it, by command line, or via the Ubuntu Software Center? If via command line, which command did you use? Did you configure it, of so how? – user68186 Mar 26 '18 at 12:14
1

First you could edit your keymap file to change the behavior of the power button to assign it to an other key

Edit the file : /usr/share/X11/xkb/symbols/inet (edit POWR key)

Then you will need to disable the power button efficiently a good method is with xinput

run xinput --list power buttons have their own entry... pick the device number then run

xinput disable devnumber something like xinput disable 8

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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