fix the battery status printing in %status

This commit is contained in:
jasper 2012-10-08 10:07:41 +00:00
parent 9ee7a0d751
commit 74f70017e8
2 changed files with 44 additions and 2 deletions

View File

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

View File

@ -0,0 +1,42 @@
$OpenBSD: patch-src_print_battery_info_c,v 1.3 2012/10/08 10:07:41 jasper Exp $
- fix the battery status printing in %status.
--- 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
@@ -228,7 +228,7 @@ void print_battery_info(yajl_gen json_gen, char *buffe
* probing acpi(4) devices.
*/
struct apm_power_info apm_info;
- int apm_fd, ac_status, charging;
+ int apm_fd, charging;
apm_fd = open("/dev/apm", O_RDONLY);
if (apm_fd < 0) {
@@ -249,14 +249,14 @@ void print_battery_info(yajl_gen json_gen, char *buffe
switch(apm_info.ac_state) {
case APM_AC_OFF:
- ac_status = CS_DISCHARGING;
+ status = CS_DISCHARGING;
break;
case APM_AC_ON:
- ac_status = CS_CHARGING;
+ status = CS_CHARGING;
break;
default:
/* If we don't know what's going on, just assume we're discharging. */
- ac_status = CS_DISCHARGING;
+ status = CS_DISCHARGING;
break;
}
@@ -264,7 +264,7 @@ 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;
(void)snprintf(remainingbuf, sizeof(remainingbuf), (charging ? "%s" : "%d"),