Bug 399727 - Support systemd suspend-then-hibernate
Summary: Support systemd suspend-then-hibernate
Status: RESOLVED FIXED
Alias: None
Product: Powerdevil
Classification: Plasma
Component: general (show other bugs)
Version: 5.13.5
Platform: Arch Linux Linux
: NOR wishlist
Target Milestone: ---
Assignee: Plasma Bugs List
URL:
Keywords:
: 400615 (view as bug list)
Depends on:
Blocks:
 
Reported: 2018-10-12 15:45 UTC by jo.lemaitresamra
Modified: 2019-12-01 10:40 UTC (History)
9 users (show)

See Also:
Latest Commit:
Version Fixed In: 5.17.0
Sentry Crash Report:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description jo.lemaitresamra 2018-10-12 15:45:30 UTC
SUMMARY
systemd provide the suspend-then-hibernate command that suspend for a certain delay (specified in /etc/systemd/sleep.conf under the HibernateDelaySec parameter), then hibernate the computer.

This command is useful since many new computers does not support suspend to S3, so suspend does a s2idle action, where the battery (of my XPS 13 9365) empty in 5 hours. suspend-then-hibernate is for the owner of such machine a nice way of combining fast startup during the day while making sure the battery is not depleted.

I know that I can set suspend-then-hibernate as lid action in logind.conf, however since powerdevil inhibit lid close (even when button event handling is disabled, maybe the bug is here) it does not work.

And I cannot kill powerdevil because it brings a lot of nice features (thanks !)

STEPS TO REPRODUCE
1. Go to energy settings
2. 
3. 

OBSERVED RESULT
Lid close action cannot be setup to suspend-then-hibernate

EXPECTED RESULT
Lid close action can be set to suspend-then-hibernate. Or at list let logind setup work when button event handling is disabled

SOFTWARE VERSIONS
(available in About System)
KDE Plasma Version:  5.13.5
KDE Frameworks Version: 5.50.0
Qt Version: 5.11.2

ADDITIONAL INFORMATION
Comment 1 Kai Uwe Broulik 2018-10-15 06:40:34 UTC
This is separate from hybrid-sleep I presume?
Comment 2 jo.lemaitresamra 2018-10-15 06:54:04 UTC
(In reply to Kai Uwe Broulik from comment #1)
> This is separate from hybrid-sleep I presume?

Yes. If I understood well, hybrid-sleep means that a suspend action is performed, with an additional save to disk of the ram content (as if we hibernated). Meaning that if the power goes off (or the battery deplete in the case of a laptop), the memory content will still be available on reboot (transforming suspend into hibernate). 

In the case of laptops without S3, that means that the battery will be depleted as with suspend, which is avoided with suspend-then-hibernate.
Comment 3 Kai Uwe Broulik 2018-10-15 07:30:03 UTC
Okay, sounds interesting. Perhaps the best approach would be to have a setting in PowerDevil where you can configure "[x] Automatically hibernate when suspended for [n minutes]" if supported. I didn't find a DBus interface to change the time, so this must perhaps be done by the user explicitly, but I can surely check for being supported and trigger it.
Comment 4 jo.lemaitresamra 2018-10-15 08:50:00 UTC
Thanks for your answers. 
I like your idea of ux, as this is something to configure in addition to current powerdevil settings.

I don't know much about DBus. In a systemd way, the delay is set in a config file (see Description).

I would be glad to report to DBus if appropriate but I really have no idea on how to do it. The function is quite recent and comes with systemd 239, so that might explain the lack of interface.

If there is anything I can do to help on this issue, please tell me :)
Comment 5 Patrick Silva 2018-11-03 11:24:40 UTC
*** Bug 400615 has been marked as a duplicate of this bug. ***
Comment 6 Sheykhnur 2018-11-28 14:47:38 UTC
Currently you can use a workaround:
ln -s /usr/lib/systemd/system/systemd-suspend-then-hibernate.service /etc/systemd/system/systemd-suspend.service
as the powerdevil operates suspend correctly.
Comment 7 Eric Adams 2019-06-06 13:44:42 UTC
Not sure if this adds anything meaningful to the discussion but I have been getting around this by setting /sys/power/mem_sleep to 'deep' instead of 's2idle' on my Dell XPS 15 9570. This allows for an actual sleep state. The only issue I have encountered is occasionally the pstate of the processor gets stuck at maximum so instead of the normal 800MHz idle state they cores all remain at 3800+ MHz and the only way to fix it is to reboot.
Comment 8 Méven Car 2019-07-01 21:47:12 UTC
Git commit daa06ba31ff1a90da7efc4b6b33459f0d2f598b0 by Méven Car, on behalf of Alejandro Valdes.
Committed on 01/07/2019 at 17:40.
Pushed by meven into branch 'master'.

Added new Suspend then Hibernate option

Summary:
See [[ https://bugs.kde.org/show_bug.cgi?id=399727 | bug 399727 ]] for a good description of what this code is for.

The new ui will show a new option like the following image {F6349860}

Reviewers: broulik, ngraham, meven, davidedmundson, sitter

Reviewed By: ngraham, meven, davidedmundson, sitter

Subscribers: sitter, davidedmundson, ericadams, jobauer, reverendhomer, meven, soriano, abalaji, graesslin, ngraham, plasma-devel

Tags: #plasma

Differential Revision: https://phabricator.kde.org/D16425

M  +14   -9    daemon/actions/bundled/suspendsession.cpp
M  +1    -0    daemon/actions/bundled/suspendsession.h
M  +21   -3    daemon/actions/bundled/suspendsessionconfig.cpp
M  +2    -0    daemon/actions/bundled/suspendsessionconfig.h
M  +3    -0    daemon/backends/upower/login1suspendjob.cpp
M  +5    -0    daemon/backends/upower/powerdevilupowerbackend.cpp
M  +1    -1    daemon/backends/upower/upowersuspendjob.cpp
M  +6    -0    daemon/org.freedesktop.PowerManagement.xml
M  +2    -1    daemon/powerdevilbackendinterface.h
M  +5    -0    daemon/powerdevilfdoconnector.cpp
M  +3    -0    daemon/powerdevilfdoconnector.h
M  +34   -0    daemon/powerdevilpowermanagement.cpp
M  +4    -0    daemon/powerdevilpowermanagement.h

https://commits.kde.org/powerdevil/daa06ba31ff1a90da7efc4b6b33459f0d2f598b0
Comment 9 Julius B. 2019-12-01 10:40:51 UTC
As someone who was looking for the suspend-then-sleep action in Plasma for quite some time, I was confused by the UI choice.

What I wanted to configure was suspend-then-sleep when closing the lid. I was looking for a respective option in the "Buttons event handling" section (which, btw, is also an odd name for lid-closing actions. I know it's correct from a technical point of view, but for non-technical users, it doesn't). I didn't see that I had to select "Suspend" there, and enable the "-then-hibernate" part in a different section that has nothing to do with lid closing (which is even above the "Buttons event handling" section).

FWIW, I liked the original suggestion with a separate "Sleep/Suspend, then hibernate" option much better, because it allowed for separate actions (with or without "-then-hibernate") for lid-closing, power button, and automatic timeout. This doesn't seem possible with the current UI.