How to set power button to shutdown instead of suspend?
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:
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.
As @don_crissti explained, the situation is silly because it really isn't possible to just shutdown without confirmation using the normal settings.
However, there's a workaround: if the chassis type of the machine is set to "vm" (virtual machine), the old immediate shutdown behavior will take over any settings. Simply enter as root:
hostnamectl set-chassis vm
and reboot once. I don't know of any side effects of this settings.
In Ubuntu 18.04 or any similar Linux variants with acpi (if not you can probably install),
make a file called /etc/acpi/events/power
with
sudo nano /etc/acpi/events/power
and put
event=button/power
action=/sbin/poweroff
inside the file, close it, then
sudo service acpid restart
This is probably the simplest solution that definitely works.