lcpz / lain

Awesome WM complements
GNU General Public License v2.0
1.06k stars 212 forks source link

Create NVIDIA GPU usage/temperature widget #548

Open tronfy opened 1 year ago

tronfy commented 1 year ago

Adds widget/contrib/nvidia.lua, for accessing NVIDIA GPU usage and temperature info.

Requires nvidia-smi to be installed. This is made clear in a comment and in the proposed wiki page for the widget.

Proposed wiki page: https://github.com/tronfy/lain/wiki/nvidia

lcpz commented 1 year ago

As this widget is quite simple, I'd suggest creating a watch recipe instead:

local nvidia = awful.widget.watch( -- dependency: nvidia-smi
    "nvidia-smi --query-gpu=utilization.gpu,temperature.gpu --format=csv,noheader,nounits",
    5, -- timeout in seconds
    function(widget, stdout)
        local usage, temp = stdout:match("([^,]+),([^,]+)")

        widget:set_text(string.format("%d%% %.1f", usage, temp)) -- customize here
end)

Please create a PR to awesome-www. See here for previous examples.