GNOME3 Power Management – How to Set Power Button to Shutdown Instead of Suspend

gnome3power-management

I am using GNOME 3.18.1 on Arch Linux 4.2.5-1-ARCH x86_64 on a Dell E6530 laptop. Since I installed this OS years ago, the power button on my laptop has always led my OS to completely power down.

However, in the last few weeks this behaviour has changed, so that pressing the power button now puts my laptop into energy savings mode. I did not change my power settings. I always keep my system up to date using pacman -Syyu, however, so I suspect that an update changed this functionality.

In the power settings there is no option for this.

How can I restore the initial behaviour, so that pressing that button powers the system off?

Best Answer

That's caused by the latest gnome-settings-daemon updates...
There is no such option in power settings because it was removed by the GNOME devs (the shutdown/power off action is considered "too destructive").
Bottom line: you can no longer power off your laptop by pressing the power off button.


You could however add a new dconf/gsettings option (i.e.shutdown) to the settings daemon power plugin if you're willing to patch and rebuild gnome-settings-daemon:

--- gnome-settings-daemon-3.18.2/data/gsd-enums.h   2015-11-10 09:07:12.000000000 -0500
+++ gnome-settings-daemon-3.18.2/data/gsd-enums.h   2015-11-11 18:43:43.240794875 -0500
@@ -114,7 +114,8 @@
 {
   GSD_POWER_BUTTON_ACTION_NOTHING,
   GSD_POWER_BUTTON_ACTION_SUSPEND,
-  GSD_POWER_BUTTON_ACTION_HIBERNATE
+  GSD_POWER_BUTTON_ACTION_HIBERNATE,
+  GSD_POWER_BUTTON_ACTION_SHUTDOWN
 } GsdPowerButtonActionType;

 typedef enum
--- gnome-settings-daemon-3.18.2/plugins/media-keys/gsd-media-keys-manager.c    2015-11-10 09:07:12.000000000 -0500
+++ gnome-settings-daemon-3.18.2/plugins/media-keys/gsd-media-keys-manager.c    2015-11-11 18:47:52.388602012 -0500
@@ -1849,6 +1849,9 @@

         action_type = g_settings_get_enum (manager->priv->power_settings, "power-button-action");
         switch (action_type) {
+        case GSD_POWER_BUTTON_ACTION_SHUTDOWN:
+                do_config_power_action (manager, GSD_POWER_ACTION_SHUTDOWN, in_lock_screen);
+                break;
         case GSD_POWER_BUTTON_ACTION_SUSPEND:
                 do_config_power_action (manager, GSD_POWER_ACTION_SUSPEND, in_lock_screen);
                 break;

Once you install the patched version, a new shutdown option will be available in dconf-editor under org > gnome > settings-daemon > plugins > power > power-button-action:

enter image description here

so select that to shutdown via power button or, if you prefer CLI, run in terminal:

gsettings set org.gnome.settings-daemon.plugins.power power-button-action shutdown

Sure, for the above to work you also need the right settings in /etc/systemd/logind.conf:

HandlePowerKey=poweroff
PowerKeyIgnoreInhibited=yes

Keep in mind that pressing the power button will shutdown your system without any warning.

Related Question