From f05b4bb9a7a70092641f43486fc7a45c85fc9c63 Mon Sep 17 00:00:00 2001 From: Mike Yuan Date: Fri, 17 Mar 2023 15:13:56 +0800 Subject: [PATCH] sleep: fix default values unmatched with manual --- man/systemd-sleep.conf.xml | 2 +- src/sleep/sleep.c | 5 ++++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/man/systemd-sleep.conf.xml b/man/systemd-sleep.conf.xml index 79ebef1fefc..f8f1694b57d 100644 --- a/man/systemd-sleep.conf.xml +++ b/man/systemd-sleep.conf.xml @@ -197,7 +197,7 @@ capacity level and estimate battery discharging rate, which is used for estimating timespan until the system battery charge level goes down to 5%. Only used by systemd-suspend-then-hibernate.service8. - Defaults to 2h. + Defaults to 1h. diff --git a/src/sleep/sleep.c b/src/sleep/sleep.c index f7fee4a14cc..f82a90dc1b2 100644 --- a/src/sleep/sleep.c +++ b/src/sleep/sleep.c @@ -39,6 +39,8 @@ #include "strv.h" #include "time-util.h" +#define DEFAULT_HIBERNATE_DELAY_USEC_NO_BATTERY (2 * USEC_PER_HOUR) + static SleepOperation arg_operation = _SLEEP_OPERATION_INVALID; static int write_hibernate_location_info(const HibernateLocation *hibernate_location) { @@ -292,7 +294,8 @@ static int custom_timer_suspend(const SleepConfig *sleep_config) { if (hashmap_isempty(last_capacity)) /* In case of no battery, system suspend interval will be set to HibernateDelaySec= or 2 hours. */ - suspend_interval = timestamp_is_set(hibernate_timestamp) ? sleep_config->hibernate_delay_usec : DEFAULT_SUSPEND_ESTIMATION_USEC; + suspend_interval = timestamp_is_set(hibernate_timestamp) + ? sleep_config->hibernate_delay_usec : DEFAULT_HIBERNATE_DELAY_USEC_NO_BATTERY; else { r = get_total_suspend_interval(last_capacity, &suspend_interval); if (r < 0) { -- 2.47.3