]> git.sur5r.net Git - i3/i3status/commitdiff
Enable colored output for battery on FreeBSD
authorBaptiste Daroussin <bapt@FreeBSD.org>
Tue, 19 Mar 2013 18:23:01 +0000 (19:23 +0100)
committerMichael Stapelberg <michael@stapelberg.de>
Tue, 19 Mar 2013 18:54:15 +0000 (19:54 +0100)
src/print_battery_info.c

index c9eee2346edf4cf333b28a0f698904c9e6ae691d..3fc31e07b6ad66da253a14e360fa458f466e3e77 100644 (file)
@@ -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__)
        /*