From 8ae40efa30eb75df0abd5303cdc774b1c54e4e63 Mon Sep 17 00:00:00 2001 From: Nikolay Polyarniy Date: Thu, 10 Dec 2015 01:30:37 +0300 Subject: [PATCH] gpu_temp: GPU temperature module (nvidia-smi only) --- i3pystatus/gpu_temp.py | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 i3pystatus/gpu_temp.py diff --git a/i3pystatus/gpu_temp.py b/i3pystatus/gpu_temp.py new file mode 100644 index 0000000..2f0aacf --- /dev/null +++ b/i3pystatus/gpu_temp.py @@ -0,0 +1,34 @@ +from i3pystatus import IntervalModule +from .utils import gpu + + +class GPUTemperature(IntervalModule): + """ + Shows GPU temperature + + Currently Nvidia only and nvidia-smi required + + .. rubric:: Available formatters + + * `{temp}` — the temperature in integer degrees celsius + """ + + settings = ( + ("format", "format string used for output. {temp} is the temperature in integer degrees celsius"), + "color", + "alert_temp", + "alert_color", + ) + format = "{temp} °C" + color = "#FFFFFF" + alert_temp = 90 + alert_color = "#FF0000" + + def run(self): + temp = gpu.query_nvidia_smi().temp + temp_alert = temp is None or temp >= self.alert_temp + + self.output = { + "full_text": self.format.format(temp=temp), + "color": self.color if not temp_alert else self.alert_color, + }