- fix the display of remaining minutes when we're discharging.

This commit is contained in:
jasper 2012-10-08 10:20:50 +00:00
parent 622dc97f96
commit 3fa4068f21
2 changed files with 17 additions and 8 deletions

View File

@ -1,11 +1,11 @@
# $OpenBSD: Makefile,v 1.10 2012/10/08 10:07:41 jasper Exp $
# $OpenBSD: Makefile,v 1.11 2012/10/08 10:20:50 jasper Exp $
ONLY_FOR_ARCHS= ${APM_ARCHS}
COMMENT= generate a statusbar for use with i3/xmobar/dzen2
DISTNAME= i3status-2.6
REVISION= 1
REVISION= 2
CATEGORIES= x11 sysutils
HOMEPAGE= http://i3wm.org/i3status/

View File

@ -1,9 +1,10 @@
$OpenBSD: patch-src_print_battery_info_c,v 1.3 2012/10/08 10:07:41 jasper Exp $
$OpenBSD: patch-src_print_battery_info_c,v 1.4 2012/10/08 10:20:50 jasper Exp $
- fix the battery status printing in %status.
- fix remaining time when we're charging.
--- src/print_battery_info.c.orig Wed Oct 3 13:44:44 2012
+++ src/print_battery_info.c Mon Oct 8 13:51:50 2012
+++ src/print_battery_info.c Mon Oct 8 14:16:30 2012
@@ -228,7 +228,7 @@ void print_battery_info(yajl_gen json_gen, char *buffe
* probing acpi(4) devices.
*/
@ -31,12 +32,20 @@ $OpenBSD: patch-src_print_battery_info_c,v 1.3 2012/10/08 10:07:41 jasper Exp $
break;
}
@@ -264,7 +264,7 @@ void print_battery_info(yajl_gen json_gen, char *buffe
@@ -264,11 +264,11 @@ void print_battery_info(yajl_gen json_gen, char *buffe
(void)snprintf(percentagebuf, sizeof(percentagebuf), "%02d%%", apm_info.battery_life);
/* Can't give a meaningful value for remaining minutes if we're charging. */
- if (ac_status == CS_CHARGING)
+ if (status == CS_CHARGING)
charging = 1;
- charging = 1;
-
- (void)snprintf(remainingbuf, sizeof(remainingbuf), (charging ? "%s" : "%d"),
- (charging ? "(CHR)" : apm_info.minutes_left));
+ if (status != CS_CHARGING) {
+ (void)snprintf(remainingbuf, sizeof(remainingbuf), "%d", apm_info.minutes_left);
+ } else {
+ (void)snprintf(remainingbuf, sizeof(remainingbuf), "%s", "(CHR)");
+ }
#endif
(void)snprintf(remainingbuf, sizeof(remainingbuf), (charging ? "%s" : "%d"),
#define EAT_SPACE_FROM_OUTPUT_IF_EMPTY(_buf) \