[hackers] [slstatus] battery: fixed remaining time on connected AC || Tobias Tschinkowitz

From: <git_AT_suckless.org>
Date: Fri, 18 May 2018 16:36:01 +0200 (CEST)

commit 367f8a8c44fc9dc05a0f7a2c1500111ca97f669c
Author: Tobias Tschinkowitz <he4d_AT_posteo.de>
AuthorDate: Fri May 18 16:33:51 2018 +0200
Commit: Aaron Marcher <me_AT_drkhsh.at>
CommitDate: Fri May 18 16:35:32 2018 +0200

    battery: fixed remaining time on connected AC
    
    when an AC is connected apm_info shows a non-valid value for remaining
    minutes. it was decided that in that case the function should return an
    empty string.

diff --git a/components/battery.c b/components/battery.c
index 53d94b5..84b2c11 100644
--- a/components/battery.c
+++ b/components/battery.c
_AT_@ -121,8 +121,12 @@
                 struct apm_power_info apm_info;
 
                 if (load_apm_power_info(&apm_info)) {
- return bprintf("%u:%02u", apm_info.minutes_left / 60,
- apm_info.minutes_left % 60);
+ if (apm_info.ac_state != APM_AC_ON) {
+ return bprintf("%u:%02u", apm_info.minutes_left / 60,
+ apm_info.minutes_left % 60);
+ } else {
+ return strdup("");
+ }
                 }
 
                 return NULL;
Received on Fri May 18 2018 - 16:36:01 CEST

This archive was generated by hypermail 2.3.0 : Fri May 18 2018 - 16:36:30 CEST