From 3c6d2167e58c909c78a04a50914b9870791326b2 Mon Sep 17 00:00:00 2001 From: Alex Corkwell Date: Sat, 15 Apr 2017 03:58:00 -0400 Subject: [PATCH] uptime: Check seconds_alert against raw seconds (#555) Originally, uptime checked seconds_alert against seconds to determine whether to use color_alert, but if {days}, {hours}, or {mins} is used in the format string, seconds is truncated to exclude anything above a day, hour, or minute respectively. This caused seconds to always be below a seconds_alert value greater than a day, for example, if {days} is used, so the alert color was never used. Fix this by saving and checking against the raw seconds that were originally read. --- i3pystatus/uptime.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/i3pystatus/uptime.py b/i3pystatus/uptime.py index 953f133..9d9b1ef 100644 --- a/i3pystatus/uptime.py +++ b/i3pystatus/uptime.py @@ -34,6 +34,8 @@ class Uptime(IntervalModule): with open(self.file, "r") as f: seconds = int(float(f.read().split()[0])) + raw_seconds = seconds + days = seconds // (60 * 60 * 24) hours = seconds // (60 * 60) minutes = seconds // 60 @@ -56,7 +58,7 @@ class Uptime(IntervalModule): } self.data = fdict if self.alert: - if seconds > self.seconds_alert: + if raw_seconds > self.seconds_alert: self.color = self.color_alert self.output = { "full_text": formatp(self.format, **fdict),