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.
This commit is contained in:
parent
4611295475
commit
b901cec5a6
@ -11,6 +11,7 @@ class Temperature(IntervalModule):
|
|||||||
settings = (
|
settings = (
|
||||||
("format",
|
("format",
|
||||||
"format string used for output. {temp} is the temperature in degrees celsius"),
|
"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",
|
"color",
|
||||||
"file",
|
"file",
|
||||||
"alert_temp",
|
"alert_temp",
|
||||||
@ -21,11 +22,13 @@ class Temperature(IntervalModule):
|
|||||||
file = "/sys/class/thermal/thermal_zone0/temp"
|
file = "/sys/class/thermal/thermal_zone0/temp"
|
||||||
alert_temp = 90
|
alert_temp = 90
|
||||||
alert_color = "#FF0000"
|
alert_color = "#FF0000"
|
||||||
|
display_if = 'True'
|
||||||
|
|
||||||
def run(self):
|
def run(self):
|
||||||
with open(self.file, "r") as f:
|
with open(self.file, "r") as f:
|
||||||
temp = float(f.read().strip()) / 1000
|
temp = float(f.read().strip()) / 1000
|
||||||
|
|
||||||
|
if eval(self.display_if):
|
||||||
self.output = {
|
self.output = {
|
||||||
"full_text": self.format.format(temp=temp),
|
"full_text": self.format.format(temp=temp),
|
||||||
"color": self.color if temp < self.alert_temp else self.alert_color,
|
"color": self.color if temp < self.alert_temp else self.alert_color,
|
||||||
|
Loading…
Reference in New Issue
Block a user