ENH make processor not puke if coretemps paths not found
This commit is contained in:
parent
a6d1175a73
commit
348eafc1cc
|
@ -70,7 +70,6 @@ return function(update_freq, config, main_state, common, width, point)
|
||||||
end
|
end
|
||||||
|
|
||||||
local mk_cores = function(y)
|
local mk_cores = function(y)
|
||||||
local coretemp_paths = cpu.get_coretemp_paths()
|
|
||||||
local core_cols = ncores / config.core_rows
|
local core_cols = ncores / config.core_rows
|
||||||
local cores = {}
|
local cores = {}
|
||||||
for c = 1, ncores do
|
for c = 1, ncores do
|
||||||
|
@ -85,6 +84,16 @@ return function(update_freq, config, main_state, common, width, point)
|
||||||
* math.floor((c - 1) / core_cols)
|
* math.floor((c - 1) / core_cols)
|
||||||
cores[c] = create_core(dial_x, dial_y)
|
cores[c] = create_core(dial_x, dial_y)
|
||||||
end
|
end
|
||||||
|
local coretemp_paths = cpu.get_coretemp_paths()
|
||||||
|
local update_coretemps = function() end
|
||||||
|
if coretemp_paths ~= nil then
|
||||||
|
update_coretemps = function()
|
||||||
|
for conky_core_id, path in pairs(coretemp_paths) do
|
||||||
|
local temp = __math_floor(0.001 * i_o.read_file(path, nil, '*n'))
|
||||||
|
common.text_circle_set(cores[conky_core_id].coretemp, temp)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
local update = function()
|
local update = function()
|
||||||
for _, load_data in pairs(mod_state) do
|
for _, load_data in pairs(mod_state) do
|
||||||
compound_dial.set(
|
compound_dial.set(
|
||||||
|
@ -93,10 +102,7 @@ return function(update_freq, config, main_state, common, width, point)
|
||||||
load_data.percent_active * 100
|
load_data.percent_active * 100
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
for conky_core_id, path in pairs(coretemp_paths) do
|
update_coretemps()
|
||||||
local temp = __math_floor(0.001 * i_o.read_file(path, nil, '*n'))
|
|
||||||
common.text_circle_set(cores[conky_core_id].coretemp, temp)
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
local static = function(cr)
|
local static = function(cr)
|
||||||
for i = 1, #cores do
|
for i = 1, #cores do
|
||||||
|
|
|
@ -184,11 +184,10 @@ M.get_cpu_number = function()
|
||||||
return tonumber(i_o.execute_cmd('nproc', nil, '*n'))
|
return tonumber(i_o.execute_cmd('nproc', nil, '*n'))
|
||||||
end
|
end
|
||||||
|
|
||||||
-- TODO what if this fails?
|
|
||||||
local get_coretemp_dir = function()
|
local get_coretemp_dir = function()
|
||||||
i_o.assert_exe_exists('grep')
|
i_o.assert_exe_exists('grep')
|
||||||
local s = i_o.execute_cmd('grep -l \'^coretemp$\' /sys/class/hwmon/*/name')
|
local s = i_o.execute_cmd('grep -l \'^coretemp$\' /sys/class/hwmon/*/name')
|
||||||
return dirname(s)
|
if s == nil then return else return dirname(s) end
|
||||||
end
|
end
|
||||||
|
|
||||||
-- map cores to integer values starting at 1; this is necessary since some cpus
|
-- map cores to integer values starting at 1; this is necessary since some cpus
|
||||||
|
@ -226,6 +225,7 @@ end
|
||||||
|
|
||||||
M.get_coretemp_paths = function()
|
M.get_coretemp_paths = function()
|
||||||
local d = get_coretemp_dir()
|
local d = get_coretemp_dir()
|
||||||
|
if d == nil then return end
|
||||||
i_o.assert_exe_exists('grep')
|
i_o.assert_exe_exists('grep')
|
||||||
local s = i_o.execute_cmd(string.format('grep Core %s/temp*_label', d))
|
local s = i_o.execute_cmd(string.format('grep Core %s/temp*_label', d))
|
||||||
local ps = {}
|
local ps = {}
|
||||||
|
|
Loading…
Reference in New Issue