contrib: add nvidia infomation widget type

This commit is contained in:
Shadowmourne G 2015-07-19 20:51:00 +08:00 committed by Jörg Thalheim
parent a31d49b00b
commit 99944631c7
No known key found for this signature in database
GPG Key ID: CA4106B8D7CC79FA
2 changed files with 43 additions and 0 deletions

View File

@ -76,6 +76,14 @@ vicious.contrib.openweather
- returns a table with string keys: {city}, {wind deg}, {wind aim},
{wind kmh}, {wind mps}, {sky}, {weather}, {temp c}, {humid}, {press}
vicious.contrib.nvinf
- provides GPU utilization, core temperature, clock frequency information
about Nvidia GPU from nvidia-settings
- takes optional card ID as an argument, i.e. "1", or defaults to ID 0
- returns first 4 values as usage of GPU core, memory, video engine and
PCIe bandwidth, 5th as temperature of requested graphics device, 6th
as frequency of GPU core, 7th as memory transfer rate
vicious.contrib.nvsmi
- provides (very basic) information about Nvidia GPU status from SMI
- takes optional card ID as an argument, i.e. "1", or defaults to ID 0

35
contrib/nvinf.lua Normal file
View File

@ -0,0 +1,35 @@
---------------------------------------------------
-- Licensed under the GNU General Public License v2
-- * (c) 2015, Ziyuan Guo <s10e.cn@gmail.com>
---------------------------------------------------
-- {{{ Grab environment
local tonumber = tonumber
local io = { popen = io.popen }
local string = { gmatch = string.gmatch }
local setmetatable = setmetatable
local helpers = require("vicious.helpers")
-- }}}
-- vicious.widgets.nvinf
local nvinf = {}
-- {{{ NVIDIA infomation widget type
local function worker(format, warg)
if not warg then warg = "0" end
local nv_inf = {}
local f = io.popen("LC_ALL=C nvidia-settings -q GPUUtilization -q [gpu:"..helpers.shellquote(warg).."]/GPUCoreTemp -q [gpu:"..helpers.shellquote(warg).."]/GPUCurrentClockFreqs -t")
local all_info = f:read("*all")
f:close()
for num in string.gmatch(all_info, "%d+") do
nv_inf[#nv_inf + 1] = tonumber(num)
end
return nv_inf
end
-- }}}
return setmetatable(nvinf, { __call = function(_, ...) return worker(...) end })