8

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.

  • 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 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. – WinEunuuchs2Unix Oct 4 at 0:39
  • is this helpfull? askubuntu.com/questions/1070915/… – nobody Oct 5 at 10:19
  • Did you have a chance of testing the solutions posted? – sancho.s ReinstateMonicaCellio Oct 5 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 at 16:00
1
+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'

| improve this answer | |
3

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

| improve this answer | |
  • 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? – WinEunuuchs2Unix Oct 4 at 0:41
  • @WinEunuuchs2Unix - Confirmed. The name of the handler can be almost anything, see updated answer for the detail. – sancho.s ReinstateMonicaCellio Oct 4 at 22:17
2

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

| improve this answer | |
  • The only answer that worked for me, and it's the easiest one so far. Thanks. – Sumit 2 days ago

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.