From b797e46c0405193a09e4329e387f2006c91da9c2 Mon Sep 17 00:00:00 2001 From: ndwarshuis Date: Sun, 24 Sep 2023 20:21:41 -0400 Subject: [PATCH] WIP don't query GPU unless we need to --- src/modules/graphics.lua | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/modules/graphics.lua b/src/modules/graphics.lua index fa5e443..27cfe7c 100644 --- a/src/modules/graphics.lua +++ b/src/modules/graphics.lua @@ -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