gpu_temp: add "display_if" setting
Adds a "display_if" setting to the gpu_temp module that allows the output to be squelched unless some snippet has been evaluated as true.
This commit is contained in:
parent
4611295475
commit
cc3781a6c0
@ -15,6 +15,7 @@ class GPUTemperature(IntervalModule):
|
|||||||
|
|
||||||
settings = (
|
settings = (
|
||||||
("format", "format string used for output. {temp} is the temperature in integer degrees celsius"),
|
("format", "format string used for output. {temp} is the temperature in integer degrees celsius"),
|
||||||
|
("display_if", "snippet that gets evaluated. if true, displays the module output"),
|
||||||
"color",
|
"color",
|
||||||
"alert_temp",
|
"alert_temp",
|
||||||
"alert_color",
|
"alert_color",
|
||||||
@ -23,12 +24,14 @@ class GPUTemperature(IntervalModule):
|
|||||||
color = "#FFFFFF"
|
color = "#FFFFFF"
|
||||||
alert_temp = 90
|
alert_temp = 90
|
||||||
alert_color = "#FF0000"
|
alert_color = "#FF0000"
|
||||||
|
display_if = True
|
||||||
|
|
||||||
def run(self):
|
def run(self):
|
||||||
temp = gpu.query_nvidia_smi().temp
|
temp = gpu.query_nvidia_smi().temp
|
||||||
temp_alert = temp is None or temp >= self.alert_temp
|
temp_alert = temp is None or temp >= self.alert_temp
|
||||||
|
|
||||||
self.output = {
|
if eval(self.display_if):
|
||||||
"full_text": self.format.format(temp=temp),
|
self.output = {
|
||||||
"color": self.color if not temp_alert else self.alert_color,
|
"full_text": self.format.format(temp=temp),
|
||||||
}
|
"color": self.color if not temp_alert else self.alert_color,
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user