From b901cec5a6fd42475d47ab8242c803112e80affa Mon Sep 17 00:00:00 2001 From: David Wahlstrom Date: Wed, 11 May 2016 13:38:28 -0700 Subject: [PATCH] temp: add a "display_if" setting Adds a "display_if" setting to temp module. This is a snippet that will be evaulated, and if the result is true, it will display the module's output. --- i3pystatus/temp.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/i3pystatus/temp.py b/i3pystatus/temp.py index 9e37ade..cb42667 100644 --- a/i3pystatus/temp.py +++ b/i3pystatus/temp.py @@ -11,6 +11,7 @@ class Temperature(IntervalModule): settings = ( ("format", "format string used for output. {temp} is the temperature in degrees celsius"), + ('display_if', 'snippet that gets evaluated. if true, displays the module output'), "color", "file", "alert_temp", @@ -21,12 +22,14 @@ class Temperature(IntervalModule): file = "/sys/class/thermal/thermal_zone0/temp" alert_temp = 90 alert_color = "#FF0000" + display_if = 'True' def run(self): with open(self.file, "r") as f: temp = float(f.read().strip()) / 1000 - self.output = { - "full_text": self.format.format(temp=temp), - "color": self.color if temp < self.alert_temp else self.alert_color, - } + if eval(self.display_if): + self.output = { + "full_text": self.format.format(temp=temp), + "color": self.color if temp < self.alert_temp else self.alert_color, + }