]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
sleep: fix default values unmatched with manual
authorMike Yuan <me@yhndnzj.com>
Fri, 17 Mar 2023 07:13:56 +0000 (15:13 +0800)
committerMike Yuan <me@yhndnzj.com>
Fri, 17 Mar 2023 18:28:22 +0000 (02:28 +0800)
man/systemd-sleep.conf.xml
src/sleep/sleep.c

index 79ebef1fefc01f1e03118e204a6636d3bb77cb7b..f8f1694b57dbacaf47049161bc03936bbcb411b4 100644 (file)
           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
           <citerefentry><refentrytitle>systemd-suspend-then-hibernate.service</refentrytitle><manvolnum>8</manvolnum></citerefentry>.
-          Defaults to 2h.</para></listitem>
+          Defaults to 1h.</para></listitem>
       </varlistentry>
     </variablelist>
   </refsect1>
index f7fee4a14cc8e072eebe74bfd694d0f5e1952416..f82a90dc1b20608370918be45cf357e8a375b92f 100644 (file)
@@ -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) {