From 8dbadb6d4ec424f782475f6f014e148ebae6d028 Mon Sep 17 00:00:00 2001 From: Baptiste Daroussin Date: Tue, 19 Mar 2013 19:23:01 +0100 Subject: Enable colored output for battery on FreeBSD --- src/print_battery_info.c | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'src/print_battery_info.c') diff --git a/src/print_battery_info.c b/src/print_battery_info.c index c9eee23..3fc31e0 100644 --- a/src/print_battery_info.c +++ b/src/print_battery_info.c @@ -234,6 +234,15 @@ void print_battery_info(yajl_gen json_gen, char *buffer, int number, const char minutes -= (hours * 60); (void)snprintf(remainingbuf, sizeof(remainingbuf), "%02dh%02d", max(hours, 0), max(minutes, 0)); + if (strncmp(threshold_type, "percentage", strlen(threshold_type)) == 0 + && present_rate < low_threshold) { + START_COLOR("color_bad"); + colorful_output = true; + } else if (strncmp(threshold_type, "time", strlen(threshold_type)) == 0 + && remaining < (u_int) low_threshold) { + START_COLOR("color_bad"); + colorful_output = true; + } } #elif defined(__OpenBSD__) /* -- cgit v1.2.3