From 6f9abf616d63c569f8357547c74a14a9aa0ce888 Mon Sep 17 00:00:00 2001 From: tobi-wan-kenobi Date: Sun, 26 Apr 2020 16:09:45 +0200 Subject: [PATCH] [modules/nvidiagpu] Automatically hide if inactive If no nvidia card is found, hide the widget see #603 --- bumblebee/modules/nvidiagpu.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/bumblebee/modules/nvidiagpu.py b/bumblebee/modules/nvidiagpu.py index 2ce7d38..45803e4 100644 --- a/bumblebee/modules/nvidiagpu.py +++ b/bumblebee/modules/nvidiagpu.py @@ -13,15 +13,23 @@ import subprocess import bumblebee.input import bumblebee.output import bumblebee.engine +import bumblebee.util class Module(bumblebee.engine.Module): def __init__(self, engine, config): super(Module, self).__init__(engine, config, bumblebee.output.Widget(full_text=self.utilization)) - self._utilization = "Not found: 0 0/0" + self._utilization = "not found: 0°C 0/0 MiB" def utilization(self, widget): return self._utilization + def hidden(self): + hide = bumblebee.util.asbool(self.parameter("hide", False)) + + if hide and self._utilization == "not found: 0°C 0/0 MiB": + return True + return False + def update(self, widgets): sp = subprocess.Popen(['nvidia-smi', '-q'], stdout=subprocess.PIPE, stderr=subprocess.PIPE) out_str = sp.communicate()