Merge pull request #377 from 0xDEAD/format-nvidia-gpu

nvidiagpu: add format-option
This commit is contained in:
tobi-wan-kenobi 2019-04-15 20:21:14 +02:00 committed by GitHub
commit 744982cb87
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -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} {fanspeed} {clock_gpu} {clock_mem}
Requires nvidia-smi
"""
@ -32,15 +36,33 @@ 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
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
elif key == "Fan Speed":
fanspeed = val.split(" ")[0]
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,
clock_gpu = clockGpu,
clock_mem = clockMem,
fanspeed = fanspeed,
)