| Summary: | Laptop doesn't go into hibernation if in standby for a long time | ||
|---|---|---|---|
| Product: | [Applications] systemsettings | Reporter: | Tobias G. <kde-bugzilla.oink169> |
| Component: | kcm_powerdevil | Assignee: | Plasma Bugs List <plasma-bugs-null> |
| Status: | CONFIRMED --- | ||
| Severity: | normal | CC: | jpetso, kde, natalie_clarius, nate, paul.leiber, postix |
| Priority: | NOR | Keywords: | usability |
| Version First Reported In: | 5.26.4 | ||
| Target Milestone: | --- | ||
| Platform: | Other | ||
| OS: | Linux | ||
| Latest Commit: | Version Fixed/Implemented In: | ||
| Sentry Crash Report: | |||
|
Description
Tobias G.
2022-12-04 00:01:12 UTC
So, I found out that "after a while" is not strictly correct: systemd will (attempt to) hibernate the system only if it goes below 5% battery charge. Or another charge percentage that you manually specify in the systemd configuration to override the 5% default. We'll need to change the UI text to reflect this behavior. I'll take the liberty to change the bug title from the original "Laptop doesn't go into hibernation if in standby for a long time" to "Settings UI is misleading about behavior of Standby, then Hibernate". However, if your laptop runs out of battery because it won't hibernate even at 5%, please feel free to reclaim the issue under its original name :) According to https://www.freedesktop.org/software/systemd/man/latest/systemd-sleep.conf.html#suspend-then-hibernate: > When the battery level is too low (less than 5%) or a certain timespan has passed, whichever happens first > [...] > HibernateDelaySec So it should go to hibernation after 2 hours by default, so the UI doesn't say anyhting misleading. I agree that "after a while" is rather unspecific, but we can't write a fixed value because it's configurable. Ideally we would eventually have a UI for initially setting up and configuring hibernation, but that's out of scope for the issue here. Tobias, have you tested with waiting for those 2 hours? Jakob, where did you find that information? It seems to conflict with the source I linked, is one of them outdated? (In reply to Natalie Clarius from comment #3) > Jakob, where did you find that information? It seems to conflict with the > source I linked, is one of them outdated? The source you linked says: > If the system has no battery, it would be hibernated after HibernateDelaySec= has passed. If not set, then defaults to "2h". > > If the system has battery and HibernateDelaySec= is not set, low-battery alarms (ACPI _BTP) are tried first for detecting battery percentage and wake up the system for hibernation. > If not available, or HibernateDelaySec= is set, the system would regularly wake up to check the time and detect the battery percentage/discharging rate. The rate is used to schedule the next detection. > If that is also not available, SuspendEstimationSec= is used as last resort. This is basically pseudo-code. Let's interpret it in order of paragraphs: 1. The system has a battery. Therefore, the first paragraph is skipped, HibernateDelaySec remains empty and does not default to "2h". 2. The system has a battery and HibernateDelaySec is not set. Systemd will try ACPI_BTP, or as a fallback, regular wake-ups, or as a last-resort fallback, SuspendEstimationSec. So "2h" is not used at all. To be fair, the systemd documentation requires us to interpret paragraph spacing to come to this conclusion. That's a little ambiguous, do I double-checked in the source itself and confirmed my interpretation: https://github.com/systemd/systemd/blob/bf39626d610628771dee20fb4322d2fc400a46be/src/sleep/sleep.c#L379 Indeed, the DEFAULT_HIBERNATE_DELAY_USEC_NO_BATTERY ("2h") constant is only used in this no-battery condition, and sleep_config->hibernate_delay_usec defaults to infinity. So the user *can* configure a particular time for hibernating, but by default is tries hard to target the 5% remaining charge. Hi, not sure if I should jump in here or create a new bug. I am trying to get "Standby, then hibernate" working in KDE on my laptop. I have set the laptop up so that "systemctl suspend-then-hibernate" is working as expected (I tested this). However, using the KDE path, the system only goes into sleep aka suspend (I assume those to are identical) and never (after several hours at least) enters hibernate. I didn't see anything suspicious in dmesg. For testing purposes, I have set HibernateDelaySec=20 in /etc/systemd/sleep.conf (I also tried other, longer delay values). The system never enters hibernate. Following this discussion, I would expect that this means that the system should enter hibernate after 20 s in sleep. I also set SuspendEstimationSec=20, with no change. I didn't try to wait for the 5% battery value, as even if this worked, it would render the functionality useless for my purposes. The whole point of "sleep, then hibernate" from my point of view is to prevent the system from depleting the battery. As background information: In sleep/suspend, my system uses approx. 1% battery capacity per hour. This means that after 4 days at the most, the battery would be almost empty. I want my system to enter hibernate if it has been sleeping for some time, so that (almost) no battery is used. While trying to find a solution, I came across https://bbs.archlinux.org/viewtopic.php?id=306047 which seems to contradict the information in this bug report, as it refers to additional settings in ~/.config/powerdevilrc. (In reply to Paul Leiber from comment #5) > Hi, > > not sure if I should jump in here or create a new bug. > > I am trying to get "Standby, then hibernate" working in KDE on my laptop. I > have set the laptop up so that "systemctl suspend-then-hibernate" is working > as expected (I tested this). However, using the KDE path, the system only > goes into sleep aka suspend (I assume those to are identical) and never > (after several hours at least) enters hibernate. I didn't see anything > suspicious in dmesg. > > For testing purposes, I have set HibernateDelaySec=20 in > /etc/systemd/sleep.conf (I also tried other, longer delay values). The > system never enters hibernate. Following this discussion, I would expect > that this means that the system should enter hibernate after 20 s in sleep. > I also set SuspendEstimationSec=20, with no change. > > I didn't try to wait for the 5% battery value, as even if this worked, it > would render the functionality useless for my purposes. The whole point of > "sleep, then hibernate" from my point of view is to prevent the system from > depleting the battery. > > As background information: In sleep/suspend, my system uses approx. 1% > battery capacity per hour. This means that after 4 days at the most, the > battery would be almost empty. I want my system to enter hibernate if it has > been sleeping for some time, so that (almost) no battery is used. > > While trying to find a solution, I came across > https://bbs.archlinux.org/viewtopic.php?id=306047 which seems to contradict > the information in this bug report, as it refers to additional settings in > ~/.config/powerdevilrc. O.k., now I just noticed that the desired behaviour "Standby, then hibernate" occurs if the system enters standby via lid closure or inactivity timeout. If I enter standby via the KDE launcher menu, hibernation is not entered. This behaviour is inconsistent from the user's perspective, therefore I filed a new bug: https://bugs.kde.org/show_bug.cgi?id=512607 As the desired behaviour does occur, my comment in this thread can be ignored. BTW, trying to change settings in ~/.config/powerdevilrc did not seem to change the "Standby, then hibernate" behaviour. Only settings in /etc/systemd/sleep.conf seem to be relevant. |