From 79a9f13d39e19c569cd9aaa32e86e5f3675c6796 Mon Sep 17 00:00:00 2001 From: jasper Date: Mon, 8 Oct 2012 11:12:53 +0000 Subject: [PATCH] - implement colors too for threshold_type=time in the battery block. --- x11/i3status/Makefile | 4 ++-- .../patches/patch-src_print_battery_info_c | 15 +++++++++------ 2 files changed, 11 insertions(+), 8 deletions(-) diff --git a/x11/i3status/Makefile b/x11/i3status/Makefile index 1c37cdd2667..627c65ca554 100644 --- a/x11/i3status/Makefile +++ b/x11/i3status/Makefile @@ -1,11 +1,11 @@ -# $OpenBSD: Makefile,v 1.12 2012/10/08 10:33:39 jasper Exp $ +# $OpenBSD: Makefile,v 1.13 2012/10/08 11:12:53 jasper Exp $ ONLY_FOR_ARCHS= ${APM_ARCHS} COMMENT= generate a statusbar for use with i3/xmobar/dzen2 DISTNAME= i3status-2.6 -REVISION= 3 +REVISION= 4 CATEGORIES= x11 sysutils HOMEPAGE= http://i3wm.org/i3status/ diff --git a/x11/i3status/patches/patch-src_print_battery_info_c b/x11/i3status/patches/patch-src_print_battery_info_c index 264fb7b595c..b898cbb7d6f 100644 --- a/x11/i3status/patches/patch-src_print_battery_info_c +++ b/x11/i3status/patches/patch-src_print_battery_info_c @@ -1,21 +1,21 @@ -$OpenBSD: patch-src_print_battery_info_c,v 1.5 2012/10/08 10:33:39 jasper Exp $ +$OpenBSD: patch-src_print_battery_info_c,v 1.6 2012/10/08 11:12:54 jasper Exp $ - fix the battery status printing in %status. - fix remaining time when we're charging. -- use colors to indicate battery status (currently only implemented for "threshold_type=percentage" +- use colors to indicate battery status --- src/print_battery_info.c.orig Wed Oct 3 13:44:44 2012 -+++ src/print_battery_info.c Mon Oct 8 14:29:50 2012 ++++ src/print_battery_info.c Mon Oct 8 15:09:53 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; ++ int apm_fd, charging, seconds_remaining; apm_fd = open("/dev/apm", O_RDONLY); if (apm_fd < 0) { -@@ -249,26 +249,38 @@ void print_battery_info(yajl_gen json_gen, char *buffe +@@ -249,26 +249,41 @@ void print_battery_info(yajl_gen json_gen, char *buffe switch(apm_info.ac_state) { case APM_AC_OFF: @@ -37,11 +37,14 @@ $OpenBSD: patch-src_print_battery_info_c,v 1.5 2012/10/08 10:33:39 jasper Exp $ (void)snprintf(percentagebuf, sizeof(percentagebuf), "%02d%%", apm_info.battery_life); + if (status == CS_DISCHARGING && low_threshold > 0) { -+ /* XXX: Implement for "time" too. */ + if (strncmp(threshold_type, "percentage", strlen(threshold_type)) == 0 + && apm_info.battery_life < low_threshold) { + START_COLOR("color_bad"); + colorful_output = true; ++ } else if (strncmp(threshold_type, "time", strlen(threshold_type)) == 0 ++ && apm_info.minutes_left < low_threshold) { ++ START_COLOR("color_bad"); ++ colorful_output = true; + } + } +