4

How can I make GNOME 3 use Systemd hybrid-sleep instead of suspend when closing the lid or using suspend from the menu?

2 Answers 2

5

If you edit the file /etc/systemd/logind.conf, you will see that there are spcifications for handling several events, among which is, for instance:

#HandleLidSwitch=suspend

(in my case). if you remove the #, you will activate the action. You can then change it by choosing one of the available actions, ignore, poweroff, reboot, halt, suspend, hibernate, hybrid-sleep, lock, kexec.

There are also many other equivalent keys, handling all usual events. You will then have to restart the systemd-logind daemon for the new configuration to take place.

The Arch Linux Wiki page also states:

In the current version of systemd, the Handle* options will apply throughout the system unless they are "inhibited" (temporarily turned off) by a program, such as a power manager inside a desktop environment. If these inhibits are not taken, you can end up with a situation where systemd suspends your system, then when it wakes up the other power manager suspends it again.

Warning: Currently, the power managers in the newest versions of KDE and GNOME are the only ones that issue the necessary "inhibited" commands. Until the others do, you will need to set the Handle options to ignore if you want your ACPI events to be handled by Xfce, acpid or other programs.

Just allow me to add one (unsolicited, admittedly) bit of advice. I do not know whether you are running Arch Linux, Fedora or Red Hat (the three major distros currently using systemd), but when in doubt, the Arch Wiki is an excellent source of info: well explained, current, correct, exhaustive. Since you are using systemd in any case, you should use it whenever you can, it is truly precious.

2
  • 2
    The only relative options in /etc/systemd/logind.conf are ACPI events and they already exists in Gnome tweak tool or via DConf. The problem here is hybrid-sleep it is not present in the list of choices available in DConf, even though i can do it by systemctl hybrid-sleep.
    – Arch User
    Feb 21, 2014 at 19:07
  • Has anything changed since 2014? Is Hybrid Sleep now supported by GNOME on lid closing?
    – orschiro
    Aug 13, 2018 at 11:36
1

The answer by Marius didn't work for me (maybe I ran into the situation in their quote block), but the following did.

Currently, you can enable "Suspend when laptop lid is closed" in Gnome Tweaks > General (Gnome v3.32.2 at time of writing). This means that your laptop will suspend when you close the lid. So if you want to do something else, e.g., hibernate or hybrid-sleep, you can let suspend behave like one of those.

You can do this by editing /etc/systemd/sleep.conf and copying the entries from HybridSleepMode and HybridSleepState to SuspendSleepMode and SuspendSleepState as follows

[Sleep]
#AllowSuspend=yes
#AllowHibernation=yes
#AllowSuspendThenHibernate=yes
#AllowHybridSleep=yes
#SuspendMode=
#SuspendState=mem standby freeze
# Configure suspend as hybrid-sleep
SuspendMode=suspend platform shutdown
SuspendState=disk
#HibernateMode=platform shutdown
#HibernateState=disk
#HybridSleepMode=suspend platform shutdown
#HybridSleepState=disk
#HibernateDelaySec=180min

You can test if it works by running systemctl suspend and checking that it goes into hybrid-sleep instead of suspending.

Note that this implies that you can not use suspend anymore. Would you still like to use suspend, you could swap it with hybrid-sleep and make hybrid-sleep behave like suspend.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .