Scheduled Maintenance: We are aware of an issue with Google, AOL, and Yahoo services as email providers which are blocking new registrations. We are trying to fix the issue and we have several internal and external support tickets in process to resolve the issue. Please see: viewtopic.php?t=158230

 

 

 

How to add "suspend-then-hibernate" in GNOME

Graphical Environments, Managers, Multimedia & Desktop questions.
Post Reply
Message
Author
pwzhangzz
Posts: 420
Joined: 2020-11-11 17:42
Has thanked: 9 times
Been thanked: 26 times

How to add "suspend-then-hibernate" in GNOME

#1 Post by pwzhangzz »

Editing the sleep.conf file (in /etc/systemd) seems to have no effect in gnome. How to add the "suspend-then-hibernate" option in gnome?

User avatar
Head_on_a_Stick
Posts: 14114
Joined: 2014-06-01 17:46
Location: London, England
Has thanked: 81 times
Been thanked: 132 times

Re: How to add "suspend-then-hibernate" in GNOME

#2 Post by Head_on_a_Stick »

deadbang

pwzhangzz
Posts: 420
Joined: 2020-11-11 17:42
Has thanked: 9 times
Been thanked: 26 times

Re: How to add "suspend-then-hibernate" in GNOME

#3 Post by pwzhangzz »

Thanks. All the options discussed therein are the same as those that can be achieved through dconf-editor (org.gnome.settings-daemon.plugins.power). However, in both cases there are only three available options: suspend, hibernate, and do-nothing. I am interested in bringing the computer to hibernate mode after having suspended for a preset amount of time.

As I mentioned in the beginning, I think the problem (for lacking the "suspend-then-hibernate" power option) is caused by gnome overriding the systemd instruction. Is there any way to add the "suspend-then-hibernate" power option plugin for gnome? Is there such a plugin?

LE_746F6D617A7A69
Posts: 932
Joined: 2020-05-03 14:16
Has thanked: 7 times
Been thanked: 65 times

Re: How to add "suspend-then-hibernate" in GNOME

#4 Post by LE_746F6D617A7A69 »

pwzhangzz wrote: 2022-08-04 18:49 I am interested in bringing the computer to hibernate mode after having suspended for a preset amount of time.
FYI, There's no such option - the systemd option "AllowSuspendThenHibernate" name is incorrect -> It's physically impossible to perform a "suspend-then-hibernate" operation. However it's possible to perform hiberanate-then-suspend.
Suspended system simply can't perform any actions, i.e. it can't perform hibernation in suspended state.

"hiberanate-then-suspend" works by first saving the RAM data to a swap and then suspending to RAM. When the battery gets fully discharged, then the data in RAM are lost, but the system can recover its previous state from swap.

I'm not using GNOME (and it will never happen) - so I can't help with "plugins" ;)
Bill Gates: "(...) In my case, I went to the garbage cans at the Computer Science Center and I fished out listings of their operating system."
The_full_story and Nothing_have_changed

pwzhangzz
Posts: 420
Joined: 2020-11-11 17:42
Has thanked: 9 times
Been thanked: 26 times

Re: How to add "suspend-then-hibernate" in GNOME

#5 Post by pwzhangzz »

Systemd sleep.conf file provides the following sleep options:

Code: Select all

[Sleep]
#AllowSuspend=yes
#AllowHibernation=yes
#AllowSuspendThenHibernate=yes
#AllowHybridSleep=yes
#SuspendMode=
#SuspendState=mem standby freeze
#HibernateMode=platform shutdown
#HibernateState=disk
#HybridSleepMode=suspend platform shutdown
#HybridSleepState=disk
#HibernateDelaySec=180min
To enable the suspend-then-hibernate option, the following two lines need to be uncommented:

Code: Select all

AllowSuspendThenHibernate=yes
HibernateDelaySec=180min
The above configuration, if executed, will cause the system to wake up and go into hibernate mode (and, of course, turn off the computer) after suspending for, as the above example indicates, 180 minutes.

However gnome has its own sleep configuration, rendering the systemd's sleep.conf file moot.

BTW, once the system goes into the hibernation mode, power will be turned off; It's physically impossible, thereafter, to perform a "suspend-then-hibernate", or any other operation. :mrgreen: (This is different from the hybrid suspend-and-hibernate combo.)

pwzhangzz
Posts: 420
Joined: 2020-11-11 17:42
Has thanked: 9 times
Been thanked: 26 times

Re: How to add "suspend-then-hibernate" in GNOME

#6 Post by pwzhangzz »

Actually dconf/gnome has the following options:
Screenshot from 2022-08-04 15-29-17.resized.jpg
Screenshot from 2022-08-04 15-29-17.resized.jpg (93.29 KiB) Viewed 2888 times
What we need is a suspend-then-hibernate plugin.

pwzhangzz
Posts: 420
Joined: 2020-11-11 17:42
Has thanked: 9 times
Been thanked: 26 times

Re: How to add "suspend-then-hibernate" in GNOME

#7 Post by pwzhangzz »

One (stupid) workaround is to use different actions to trigger suspend and hibernation, respectively.

If I want "suspend", I'm using gnome tweaks to set lid-close to suspend. Thus, each time I want to suspend the computer I simply close the lid. For desktops I can use gnome system panel to click on suspend.

Then I use the dconf-editor to set sleep option to "hibernate after 10 minutes inaction". Recently we purchased a Zen3 based ASUS laptop, boot time is less than 10 seconds. This is actually faster than the suspend wake-up time for some of the older computers we have.

lindi
Debian Developer
Debian Developer
Posts: 412
Joined: 2022-07-12 14:10
Has thanked: 1 time
Been thanked: 77 times

Re: How to add "suspend-then-hibernate" in GNOME

#8 Post by lindi »

LE_746F6D617A7A69 wrote: 2022-08-04 21:24 FYI, There's no such option - the systemd option "AllowSuspendThenHibernate" name is incorrect -> It's physically impossible to perform a "suspend-then-hibernate" operation. However it's possible to perform hiberanate-then-suspend.
Suspended system simply can't perform any actions, i.e. it can't perform hibernation in suspended state.

"hiberanate-then-suspend" works by first saving the RAM data to a swap and then suspending to RAM. When the battery gets fully discharged, then the data in RAM are lost, but the system can recover its previous state from swap.
I believe systemd suspends, then wakes up using an alarm and then performs hibernate. It also takes care to observe the battery capacity so that the system never fully discharges the battery. Please check the source code at https://github.com/systemd/systemd/blob ... eep.c#L265

You can also check man systemd-sleep.conf:

Code: Select all

    A low power state where the system is initially suspended (the state is stored in RAM). If not interrupted within the delay specified by HibernateDelaySec=, the system will be woken using an RTC alarm and hibernated (the state is then stored on disk). 
LE_746F6D617A7A69 wrote: 2022-08-04 21:24 I'm not using GNOME (and it will never happen) - so I can't help with "plugins" ;)
I think it's not very constructive to post to GNOME questions and state that you will never use GNOME...

pwzhangzz
Posts: 420
Joined: 2020-11-11 17:42
Has thanked: 9 times
Been thanked: 26 times

Re: How to add "suspend-then-hibernate" in GNOME

#9 Post by pwzhangzz »

Gnome control center (now "Gnome Settings") also overrides configurations from dconf. In dconf, I set the power button to hibernate. However, since gnome settings does not have hibernate option, this instruction was ignored.

pwzhangzz
Posts: 420
Joined: 2020-11-11 17:42
Has thanked: 9 times
Been thanked: 26 times

Re: How to add "suspend-then-hibernate" in GNOME

#10 Post by pwzhangzz »

Forgot to mention that, at least at the present time, hibernation requires that the safe boot be turned off.

Also, although the dconf "setting the power button to hibernate" option is bypassed by gnome settings, I can set a hotkey (e.g. "ctlr + alt + h") to execute the "systemctl hibernate" command similar to the "power button to hibernate" action; this command does not need root privilege to execute (at least in Debian 12).

Post Reply