From eadc2b45c3c91a05e247c90286e710f139819233 Mon Sep 17 00:00:00 2001 From: 0xDEAD Date: Mon, 15 Apr 2019 12:30:20 +0200 Subject: [PATCH 1/2] nvidiagpu: add option to format output (default=current format) --- bumblebee/modules/nvidiagpu.py | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/bumblebee/modules/nvidiagpu.py b/bumblebee/modules/nvidiagpu.py index 8acf68c..005ff49 100644 --- a/bumblebee/modules/nvidiagpu.py +++ b/bumblebee/modules/nvidiagpu.py @@ -2,6 +2,10 @@ """Displays GPU name, temperature and memory usage. +Parameters: + * nvidiagpu.format: Format string (defaults to "{name}: {temp}°C %{usedmem}/{totalmem} MiB") + Available values are: {name} {temp} {mem_used} {mem_total} + Requires nvidia-smi """ @@ -34,13 +38,21 @@ class Module(bumblebee.engine.Module): key, val = key.strip(), val.strip() if title == "FB Memory Usage": if key == "Total": - totalMem = val + totalMem = val.split(" ")[0] elif key == "Used": usedMem = val.split(" ")[0] elif key == "GPU Current Temp": temp = val.split(" ")[0] elif key == "Product Name": name = val + except: title = item.strip() - self._utilization = u"%s: %s°C %s/%s"%(name, temp, usedMem, totalMem) + + str_format = self.parameter("format", '{name}: {temp}°C {mem_used}/{mem_total} MiB') + self._utilization = str_format.format( + name = name, + temp = temp, + mem_used = usedMem, + mem_total = totalMem, + ) From 842e4f1795801bc92abf8fe67d49b7eb72495ff9 Mon Sep 17 00:00:00 2001 From: 0xDEAD Date: Mon, 15 Apr 2019 12:31:24 +0200 Subject: [PATCH 2/2] nvidiagpu: add gpu/mem clock and fan-speed --- bumblebee/modules/nvidiagpu.py | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/bumblebee/modules/nvidiagpu.py b/bumblebee/modules/nvidiagpu.py index 005ff49..810e182 100644 --- a/bumblebee/modules/nvidiagpu.py +++ b/bumblebee/modules/nvidiagpu.py @@ -4,7 +4,7 @@ Parameters: * nvidiagpu.format: Format string (defaults to "{name}: {temp}°C %{usedmem}/{totalmem} MiB") - Available values are: {name} {temp} {mem_used} {mem_total} + Available values are: {name} {temp} {mem_used} {mem_total} {fanspeed} {clock_gpu} {clock_mem} Requires nvidia-smi """ @@ -36,6 +36,11 @@ class Module(bumblebee.engine.Module): try: key, val = item.split(':') key, val = key.strip(), val.strip() + if title == "Clocks": + if key == "Graphics": + clockGpu = val.split(" ")[0] + elif key == "Memory": + clockMem = val.split(" ")[0] if title == "FB Memory Usage": if key == "Total": totalMem = val.split(" ")[0] @@ -45,6 +50,8 @@ class Module(bumblebee.engine.Module): temp = val.split(" ")[0] elif key == "Product Name": name = val + elif key == "Fan Speed": + fanspeed = val.split(" ")[0] except: title = item.strip() @@ -55,4 +62,7 @@ class Module(bumblebee.engine.Module): temp = temp, mem_used = usedMem, mem_total = totalMem, + clock_gpu = clockGpu, + clock_mem = clockMem, + fanspeed = fanspeed, )