WIP don't query GPU unless we need to

This commit is contained in:
Nathan Dwarshuis 2023-09-24 20:21:41 -04:00
parent ea6d5e6042
commit b797e46c04
1 changed files with 9 additions and 1 deletions

View File

@ -52,8 +52,14 @@ return function(update_freq, config, common, width, point)
vid_utilization = 0
}
local runtime_status_file = config.dev_power..'/runtime_status'
local want_nvidia_query = config.show_temp or config.show_clock
or config.gpu_util or config.mem_util or config.vid_util
local update_state = function()
if i_o.read_file(config.dev_power, nil, '*l') == 'on' then
local is_active = i_o.read_file(runtime_status_file, nil, '*l') == 'active'
if is_active and want_nvidia_query then
local nvidia_settings_glob = i_o.execute_cmd(NV_QUERY)
if nvidia_settings_glob == nil then
mod_state.error = 'Error'
@ -68,6 +74,8 @@ return function(update_freq, config, common, width, point)
= __string_match(nvidia_settings_glob, NV_REGEX)
mod_state.error = false
end
elseif is_active then
mod_state.error = false
else
mod_state.error = 'Off'
end