ENH update graphics for optimus-manager

This commit is contained in:
Nathan Dwarshuis 2020-01-30 23:48:02 -05:00
parent fa0ad15c70
commit 45a3903144
1 changed files with 43 additions and 50 deletions

View File

@ -8,7 +8,6 @@ local LabelPlot = require 'LabelPlot'
local Util = require 'Util'
local __tonumber = tonumber
local __string_find = string.find
local __string_match = string.match
local _MODULE_Y_ = 145
@ -178,7 +177,7 @@ glob will be of the form:
<gpu_freq>,<mem_freq>
graphics=<gpu_util>, memory=<mem_util>, video=<vid_util>, PCIe=<pci_util>
--]]
local NV_QUERY = 'optirun nvidia-settings -c :8 -t'..
local NV_QUERY = 'nvidia-settings -t'..
' -q UsedDedicatedGPUMemory'..
' -q TotalDedicatedGPUMemory'..
' -q ThermalSensorReading'..
@ -208,22 +207,16 @@ local nvidia_off = function(cr)
LabelPlot.update(vid_util.plot, 0)
end
local update = function(cr)
-- check if bbswitch is on
if Util.read_file('/proc/acpi/bbswitch', '.+%s+(%u+)') == 'ON' then
local gpu_bus_ctrl = '/sys/bus/pci/devices/0000:01:00.0/power/control'
-- bbswitch might be on, but only because conky is constantly querying
-- it and there appears to be some lag between closing all optirun
-- processes and flipping bbswitch off. If bbswitch is on and there are
-- no optirun processes, we call this "Mixed." In this case we don't
-- check anything (to allow bbswitch to actually switch off) and set all
-- values to N/A and 0.
if not __string_find(Util.execute_cmd('ps -A -o comm'), 'optirun') then
Text.set(status.value, cr, 'Mixed')
local update = function(cr)
if Util.read_file(gpu_bus_ctrl, nil, '*l') == 'on' then
local nvidia_settings_glob = Util.execute_cmd(NV_QUERY)
if nvidia_settings_glob == '' then
Text.set(status.value, cr, 'Error')
nvidia_off(cr)
else
Text.set(status.value, cr, 'On')
local nvidia_settings_glob = Util.execute_cmd(NV_QUERY)
local used_memory, total_memory, temp_reading, gpu_frequency,
memory_frequency, gpu_utilization, vid_utilization