From 91ea7ebcdfac18137a1f3d1e89d99917ad66d87f Mon Sep 17 00:00:00 2001 From: Sonali Srivastava Date: Wed, 20 Jul 2022 14:47:04 +0530 Subject: sleep: store battery discharge rate/hour with hash Estimated battery discharge rate per hour is stored in : /var/lib/systemd/sleep/battery_discharge_percentage_rate_per_hour This value is used to determine the initial suspend interval. In case this file is not available or value is invalid, HibernateDelaySec interval is used. After wakeup from initial suspend, this value is again estimated and written to file if value is in range of 1-199. Logs for reference : HibernateDelaySec=15min - Updated in /etc/systemd/sleep.conf Jul 14 19:17:58 localhost systemd-sleep[567]: Current battery charge percentage: 100% Jul 14 19:17:58 localhost systemd-sleep[567]: Failed to read discharge rate from /var/lib/systemd/sleep/batt ery_discharge_percentage_rate_per_hour: No such file or directory Jul 14 19:17:58 localhost systemd-sleep[567]: Set timerfd wake alarm for 15min Jul 14 19:33:00 localhost systemd-sleep[567]: Current battery charge percentage after wakeup: 90% Jul 14 19:33:00 localhost systemd-sleep[567]: Attempting to estimate battery discharge rate after wakeup from 15min sleep Jul 14 19:33:00 localhost systemd-sleep[567]: product_id does not exist: No such file or directory Jul 14 19:33:00 localhost systemd-sleep[567]: Estimated discharge rate 39 successfully updated to /var/lib/systemd/sleep/battery_discharge_percentage_rate_per_hour Jul 14 19:33:00 localhost systemd-sleep[567]: Current battery charge percentage: 90% Jul 14 19:33:00 localhost systemd-sleep[567]: product_id does not exist: No such file or directory Jul 14 19:33:00 localhost systemd-sleep[567]: Set timerfd wake alarm for 1h 48min 27s Jul 14 21:21:30 localhost systemd-sleep[567]: Current battery charge percentage after wakeup: 90% Jul 14 21:21:30 localhost systemd-sleep[567]: Battery was not discharged during suspension --- src/shared/sleep-config.h | 2 ++ 1 file changed, 2 insertions(+) (limited to 'src/shared/sleep-config.h') diff --git a/src/shared/sleep-config.h b/src/shared/sleep-config.h index 39d952b954..a48cf17a54 100644 --- a/src/shared/sleep-config.h +++ b/src/shared/sleep-config.h @@ -57,6 +57,8 @@ int can_sleep_disk(char **types); int can_sleep_state(char **types); int read_battery_capacity_percentage(void); int battery_is_low(void); +int get_battery_discharge_rate(void); +int put_battery_discharge_rate(int estimated_battery_discharge_rate); const char* sleep_operation_to_string(SleepOperation s) _const_; SleepOperation sleep_operation_from_string(const char *s) _pure_; -- cgit v1.2.3