FIX a bunch of bugs

This commit is contained in:
Nathan Dwarshuis 2022-07-21 19:16:11 -04:00
parent ca27602978
commit 0f53cccfa9
4 changed files with 24 additions and 21 deletions

View File

@ -31,7 +31,8 @@ return function(update_freq, config, common, width, point)
' -q TotalDedicatedGPUmemory'..
' -q ThermalSensorReading'..
' -q [gpu:0]/GPUCurrentClockFreqs'..
' -q [gpu:0]/GPUutilization'
' -q [gpu:0]/GPUutilization'..
' 2>/dev/null'
local NV_REGEX = '(%d+)\n'..
'(%d+)\n'..
@ -44,8 +45,6 @@ return function(update_freq, config, common, width, point)
used_memory = 0,
total_memory = 0,
temp_reading = 0,
gpu_frequency = 0,
memory_frequency = 0,
gpu_utilization = 0,
vid_utilization = 0
}

View File

@ -15,11 +15,11 @@ return function(main_state, common, width, point)
{'Total', 'Explicit', 'Outdated', 'Orphaned', 'Local'}
)
local update = function()
local stats = __string_match(
main_state.pacman_stats,
'%d+%s+[^%s]+%s+[^%s]+%s+(.*)$'
)
if stats then
if main_state.pacman_stats then
local stats = __string_match(
main_state.pacman_stats,
'%d+%s+[^%s]+%s+[^%s]+%s+(.*)$'
)
local i = 1
for v in __string_gmatch(stats, '%d+') do
common.text_rows_set(obj, i, v)

View File

@ -56,15 +56,6 @@ return function(update_freq, config, common, width, point)
-----------------------------------------------------------------------------
-- battery power plot
local _read_battery_power = sys.battery_power_reader(config.battery)
local read_battery_power = function(is_using_ac)
if is_using_ac then
return 0
else
return _read_battery_power()
end
end
local format_ac = function(watts)
if watts == 0 then
@ -75,6 +66,15 @@ return function(update_freq, config, common, width, point)
end
local mk_bat = function(y)
local _read_battery_power = sys.battery_power_reader(config.battery)
local read_battery_power = function(is_using_ac)
if is_using_ac then
return 0
else
return _read_battery_power()
end
end
local read_bat_status = sys.battery_status_reader(config.battery)
local obj = common.make_tagged_scaled_timeseries(
point.x,
@ -104,12 +104,13 @@ return function(update_freq, config, common, width, point)
-----------------------------------------------------------------------------
-- main functions
return {
header = 'POWER',
point = point,
width = width,
set_state = nil,
-- TODO make sure these interfaces actually exist before trying to read them
top = pure.concat(
pure.map(mk_rate_blockspec, config.rapl_specs),
{{mk_bat, config.battery ~= '', 0}}

View File

@ -18,15 +18,18 @@ return function(main_state, common, width, point)
common.text_rows_set(obj, 1, i_o.conky('$kernel'))
local update = function()
local last_update, last_sync
common.text_rows_set(obj, 2, i_o.conky('$uptime'))
if main_state.pacman_stats then
last_update, last_sync = __string_match(
main_state.pacman_stats,
"^%d+%s+([^%s]+)%s+([^%s]+).*"
)
common.text_rows_set(obj, 3, last_update)
common.text_rows_set(obj, 4, last_sync)
else
common.text_rows_set(obj, 3, 'N/A')
common.text_rows_set(obj, 4, 'N/A')
end
common.text_rows_set(obj, 2, i_o.conky('$uptime'))
common.text_rows_set(obj, 3, last_update)
common.text_rows_set(obj, 4, last_sync)
end
local static = pure.partial(common.text_rows_draw_static, obj)
local dynamic = pure.partial(common.text_rows_draw_dynamic, obj)