From: Mike Yuan Date: Fri, 17 Mar 2023 07:13:56 +0000 (+0800) Subject: sleep: fix default values unmatched with manual X-Git-Tag: v254-rc1~993 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=f05b4bb9a7a70092641f43486fc7a45c85fc9c63;p=thirdparty%2Fsystemd.git sleep: fix default values unmatched with manual --- 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) {