9

I disabled the power button on my desktop (pressing it did nothing, no shutdown, no hibernation/sleep, because my kids like it to press)
After I upgraded my ubuntu from 18LTS to 20LTS, the disabled power button behaviour does not work anymore. When it is pressed, it hibernates the PC.

Here are my current settings gsettings list-recursively org.gnome.settings-daemon.plugins.power

org.gnome.settings-daemon.plugins.power lid-close-ac-action 'suspend'
org.gnome.settings-daemon.plugins.power time-critical 300
org.gnome.settings-daemon.plugins.power power-button-action 'nothing'
org.gnome.settings-daemon.plugins.power lid-close-suspend-with-external-monitor false
org.gnome.settings-daemon.plugins.power button-hibernate 'nothing'
org.gnome.settings-daemon.plugins.power idle-dim true
org.gnome.settings-daemon.plugins.power button-power 'nothing'
org.gnome.settings-daemon.plugins.power lid-close-battery-action 'suspend'
org.gnome.settings-daemon.plugins.power priority 0
org.gnome.settings-daemon.plugins.power idle-brightness 30
org.gnome.settings-daemon.plugins.power active true
org.gnome.settings-daemon.plugins.power critical-battery-action 'suspend'
org.gnome.settings-daemon.plugins.power button-suspend 'nothing'
org.gnome.settings-daemon.plugins.power button-sleep 'nothing'
org.gnome.settings-daemon.plugins.power percentage-critical 3
org.gnome.settings-daemon.plugins.power sleep-inactive-ac-timeout 3600
org.gnome.settings-daemon.plugins.power sleep-inactive-ac-type 'nothing'
org.gnome.settings-daemon.plugins.power ambient-enabled true
org.gnome.settings-daemon.plugins.power notify-perhaps-recall true
org.gnome.settings-daemon.plugins.power percentage-low 10
org.gnome.settings-daemon.plugins.power percentage-action 2
org.gnome.settings-daemon.plugins.power sleep-inactive-battery-type 'suspend'
org.gnome.settings-daemon.plugins.power time-low 1200
org.gnome.settings-daemon.plugins.power sleep-inactive-battery-timeout 1200
org.gnome.settings-daemon.plugins.power time-action 120
org.gnome.settings-daemon.plugins.power use-time-for-policy true

cat /etc/systemd/logind.conf

[Login]
#NAutoVTs=6
#ReserveVT=6
#KillUserProcesses=no
#KillOnlyUsers=
#KillExcludeUsers=root
#InhibitDelayMaxSec=5
HandlePowerKey=ignore
HandleSuspendKey=ignore
HandleHibernateKey=ignore
#HandleLidSwitch=suspend
#HandleLidSwitchDocked=ignore
#PowerKeyIgnoreInhibited=no
#SuspendKeyIgnoreInhibited=no
#HibernateKeyIgnoreInhibited=no
#LidSwitchIgnoreInhibited=yes
#HoldoffTimeoutSec=30s
#IdleAction=ignore
#IdleActionSec=30min
#RuntimeDirectorySize=10%
#RemoveIPC=yes
#InhibitorsMax=8192
#SessionsMax=8192
#UserTasksMax=33%

Have you any ideas what could be wrong?
Thank you for your help.

7
  • 1
    are you for sure looking in the correct environment for which you are using? ie) com.canonical.unity.settings-daemon.plugins.power button-suspend OR org.mate.power-manager button-suspend ???? Are there any other desktops installed, if so, does the button work as expected there?
    – WU-TANG
    Oct 3, 2020 at 0:09
  • 1
    This might help: unix.stackexchange.com/questions/547582/… Another option is to raise your voice when your kids do something wrong. Oct 4, 2020 at 0:39
  • is this helpfull? askubuntu.com/questions/1070915/…
    – nobody
    Oct 5, 2020 at 10:19
  • Did you have a chance of testing the solutions posted? Oct 5, 2020 at 10:47
  • disconnect the power button from the motherboard and configure the BIOS to power on automatically when power is restored. It would require cycling the surge protector to turn in on after shutting down.
    – rtaft
    Oct 5, 2020 at 16:00

4 Answers 4

5

I am not sure what is wrong with your files.

  1. The logind-way

    Did you try

    sudo systemctl restart systemd-logind
    

    or (better) rebooting?

  2. The acpid-way

    Besides, this a possible method to obtain the behaviour you are looking for. Create an ACPI handler with a file in /etc/acpi/events/

    sudo nano /etc/acpi/events/powerbtn-acpi-support
    

    (Note: as per official info, "Rules are defined by simple configuration files. acpid will look in a configuration directory (/etc/acpi/events by default), and parse all regular files that do not begin with a period ('.') or end with a tilde (~).")

    Make that file contain

    event=button[ /]power
    action=
    

    Then restart the acpi daemon with

    sudo service acpid restart
    

Notes:

  1. The cardboard-way is funny.

Sources:

https://superuser.com/questions/1523918/run-script-when-power-button-pressed

https://wiki.archlinux.org/index.php/acpid

How to prevent the Power button to shutdown directly the system?

https://superuser.com/questions/699905/change-behavior-of-linux-power-button/699925

3
  • I saw the /etc/acpi/events/powerbtn-acpi-support reference from 2014 in a google search. That was renamed to: /etc/acpi/events/powerbtn in my Ubuntu 16.04. Did you check if it exists on your system? Oct 4, 2020 at 0:41
  • @WinEunuuchs2Unix - Confirmed. The name of the handler can be almost anything, see updated answer for the detail. Oct 4, 2020 at 22:17
  • What happens if system is crashed or partially crashed? Can I use long power press to shutdown computer? Is it the behaviour for short power press, right?
    – laimison
    Oct 19, 2022 at 0:04
3

Ubuntu 20.04 LTS has it in the GUI controls. There is an option to make the power button "Do nothing" in the Power Button Behavior dropdown menu.
*
enter image description here

1
  • The only answer that worked for me, and it's the easiest one so far. Thanks.
    – Sumit
    Nov 28, 2020 at 9:53
2
+100

Check to see if there are other desktop environments in play like:
com.canonical.unity.settings-daemon.plugins.power
or
org.mate.power-manager

You may have made the correct change, but for the wrong environment...

a more generic search of your gsettings can also help:
gsettings list-recursively | grep button on my system additionally yields:
.
.
.
com.canonical.unity.settings-daemon.plugins.power power-button-action 'suspend'
com.canonical.unity.settings-daemon.plugins.power button-hibernate 'hibernate'
com.canonical.unity.settings-daemon.plugins.power button-power 'suspend'
com.canonical.unity.settings-daemon.plugins.power button-suspend 'suspend'
com.canonical.unity.settings-daemon.plugins.power button-sleep 'hibernate'

0

For some reason, the sleep.conf is rarely if ever mentioned, I couldn't get anything else to work from the proposed solutions on Ubuntu Jammy (22.04LTS) so finally this one solved it:

$ sudo nano /etc/systemd/sleep.conf

Then, change the following lines like this to disable all power options:

AllowSuspend=no
AllowHibernation=no
AllowSuspendThenHibernate=no
AllowHybridSleep=no

After that, sudo ldconfig and/or a restart and you should be all set.

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.