&& seconds_remaining < 60 * low_threshold) {
START_COLOR("color_bad");
colorful_output = true;
+ } else {
+ colorful_output = false;
}
}
(void)snprintf(consumptionbuf, sizeof(consumptionbuf), "%1.2fW",
((float)present_rate / 1000.0 / 1000.0));
-
- if (colorful_output)
- END_COLOR;
+ } else {
+ /* On some systems, present_rate may not exist. Still, make sure
+ * we colorize the output if threshold_type is set to percentage
+ * (since we don't have any information on remaining time). */
+ if (status == CS_DISCHARGING && low_threshold > 0) {
+ if (strncmp(threshold_type, "percentage", strlen(threshold_type)) == 0
+ && percentage_remaining < low_threshold) {
+ START_COLOR("color_bad");
+ colorful_output = true;
+ }
+ }
}
#elif defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
int state;
}
}
+ if (colorful_output)
+ END_COLOR;
+
OUTPUT_FULL_TEXT(buffer);
}