From 55f8812bc9d5d4418ba59ccc36a7adfb0aa61f11 Mon Sep 17 00:00:00 2001 From: tigerjack <8199216+tigerjack@users.noreply.github.com> Date: Mon, 3 Dec 2018 12:35:31 +0100 Subject: [PATCH] temp.py: Fixed bug related to dynamic colors (#672) When a custom alert_temp was given, for any temperature value above alert_temp the module generated an "IndexError: string index out of range" error. --- i3pystatus/temp.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/i3pystatus/temp.py b/i3pystatus/temp.py index b278461..acad0c1 100644 --- a/i3pystatus/temp.py +++ b/i3pystatus/temp.py @@ -189,7 +189,10 @@ class Temperature(IntervalModule, ColorRangeModule): temp = float(f.read().strip()) / 1000 if self.dynamic_color: - color = self.colors[int(self.percentage(int(temp), self.alert_temp))] + perc = int(self.percentage(int(temp), self.alert_temp)) + if (perc > 99): + perc = 99 + color = self.colors[perc] else: color = self.color if temp < self.alert_temp else self.alert_color return {