REF remove extra cr args

This commit is contained in:
Nathan Dwarshuis 2021-07-26 23:45:54 -04:00
parent 38634b6cbc
commit 3a788149dd
10 changed files with 67 additions and 67 deletions

View File

@ -192,7 +192,7 @@ end
-- TODO this is pretty confusing, nil means -1 which gets fed to any text
-- formatting functions
M.percent_plot_set = function(pp, cr, value)
M.percent_plot_set = function(pp, value)
local t = -1
local p = 0
if value ~= nil then
@ -278,7 +278,7 @@ M.annotated_scale_plot_draw_dynamic = function(asp, cr)
ScaledTimeseries.draw_dynamic(asp.plot, cr)
end
M.annotated_scale_plot_set = function(asp, cr, value)
M.annotated_scale_plot_set = function(asp, value)
Text.set(asp.value, value)
ScaledTimeseries.update(asp.plot, value)
end
@ -322,7 +322,7 @@ M.build_rate_timeseries = function(x, y, w, h, format_fun, label_fun, spacing,
}
end
M.update_rate_timeseries = function(obj, cr, value)
M.update_rate_timeseries = function(obj, value)
local rate = obj.derive(obj.prev_value, value)
Text.set(obj.value, rate)
ScaledTimeseries.update(obj.plot, rate)
@ -381,7 +381,7 @@ M.text_ring_draw_dynamic = function(tr, cr)
ThresholdText.draw(tr.value, cr)
end
M.text_ring_set = function(tr, cr, value)
M.text_ring_set = function(tr, value)
ThresholdText.set(tr.value, value)
end
@ -407,9 +407,9 @@ M.dial = function(x, y, radius, thickness, threshold, format)
}
end
M.dial_set = function(dl, cr, value)
M.dial_set = function(dl, value)
Dial.set(dl.dial, value)
M.text_ring_set(dl.text_ring, cr, value)
M.text_ring_set(dl.text_ring, value)
end
M.dial_draw_static = function(dl, cr)
@ -510,7 +510,7 @@ M.text_row_draw_dynamic = function(row, cr)
Text.draw(row.value, cr)
end
M.text_row_set = function(row, cr, value)
M.text_row_set = function(row, value)
Text.set(row.value, value)
end
@ -541,7 +541,7 @@ M.text_row_crit_draw_dynamic = function(row, cr)
ThresholdText.draw(row.value, cr)
end
M.text_row_crit_set = function(row, cr, value)
M.text_row_crit_set = function(row, value)
ThresholdText.set(row.value, value)
end
@ -612,7 +612,7 @@ M.text_rows_draw_dynamic = function(rows, cr)
TextColumn.draw(rows.values, cr)
end
M.text_rows_set = function(rows, cr, i, value)
M.text_rows_set = function(rows, i, value)
TextColumn.set(rows.values, i, value)
end

View File

@ -63,9 +63,9 @@ return function()
-----------------------------------------------------------------------------
-- main functions
local update = function(cr)
local update = function()
local smart_pid = Util.execute_cmd('pidof smartd', nil, '*n')
Common.text_row_set(smart, cr, (smart_pid == '') and 'Error' or 'Running')
Common.text_row_set(smart, (smart_pid == '') and 'Error' or 'Running')
for i = 1, FS_NUM do
local percent = Util.conky_numeric(CONKY_USED_PERC[i])
@ -81,7 +81,7 @@ return function()
end
local draw_dynamic = function(cr, trigger)
if trigger == 0 then update(cr) end
if trigger == 0 then update() end
Common.text_row_draw_dynamic(smart, cr)
Common.compound_bar_draw_dynamic(fs, cr)
end

View File

@ -149,39 +149,39 @@ return function(update_freq)
local GPU_BUS_CTRL = '/sys/bus/pci/devices/0000:01:00.0/power/control'
local nvidia_off = function(cr)
Common.text_row_crit_set(internal_temp, cr, -1)
Common.text_rows_set(clock_speed, cr, 1, NA)
Common.text_rows_set(clock_speed, cr, 2, NA)
Common.percent_plot_set(gpu_util, cr, nil)
Common.percent_plot_set(vid_util, cr, nil)
Common.percent_plot_set(mem_util, cr, nil)
local nvidia_off = function()
Common.text_row_crit_set(internal_temp, -1)
Common.text_rows_set(clock_speed, 1, NA)
Common.text_rows_set(clock_speed, 2, NA)
Common.percent_plot_set(gpu_util, nil)
Common.percent_plot_set(vid_util, nil)
Common.percent_plot_set(mem_util, nil)
end
local update = function(cr)
local update = function()
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)
Text.set(status.value, 'Error')
nvidia_off()
else
Common.text_row_set(status, cr, 'On')
Common.text_row_set(status, 'On')
local used_memory, total_memory, temp_reading, gpu_frequency,
memory_frequency, gpu_utilization, vid_utilization
= __string_match(nvidia_settings_glob, NV_REGEX)
Common.text_row_crit_set(internal_temp, cr, temp_reading)
Common.text_rows_set(clock_speed, cr, 1, gpu_frequency..' Mhz')
Common.text_rows_set(clock_speed, cr, 2, memory_frequency..' Mhz')
Common.text_row_crit_set(internal_temp, temp_reading)
Common.text_rows_set(clock_speed, 1, gpu_frequency..' Mhz')
Common.text_rows_set(clock_speed, 2, memory_frequency..' Mhz')
Common.percent_plot_set(gpu_util, cr, gpu_utilization)
Common.percent_plot_set(mem_util, cr, used_memory / total_memory * 100)
Common.percent_plot_set(vid_util, cr, vid_utilization)
Common.percent_plot_set(gpu_util, gpu_utilization)
Common.percent_plot_set(mem_util, used_memory / total_memory * 100)
Common.percent_plot_set(vid_util, vid_utilization)
end
else
Text.set(status.value, cr, 'Off')
nvidia_off(cr)
Text.set(status.value, 'Off')
nvidia_off()
end
end
@ -206,7 +206,7 @@ return function(update_freq)
end
local draw_dynamic = function(cr)
update(cr)
update()
Common.text_row_draw_dynamic(status, cr)
Common.text_row_crit_draw_dynamic(internal_temp, cr)

View File

@ -134,7 +134,7 @@ return function(update_freq)
-----------------------------------------------------------------------------
-- main functions
local update = function(cr)
local update = function()
local conky = Util.conky
-- see manpage for free command for formulas
@ -153,13 +153,13 @@ return function(update_freq)
buffers -
sreclaimable) / memtotal
Common.dial_set(mem, cr, used_percent)
Common.dial_set(swap, cr, (swaptotal - swapfree) / swaptotal)
Common.dial_set(mem, used_percent)
Common.dial_set(swap, (swaptotal - swapfree) / swaptotal)
Common.text_rows_set(cache, cr, 1, cached / memtotal * 100)
Common.text_rows_set(cache, cr, 2, buffers / memtotal * 100)
Common.text_rows_set(cache, cr, 3, shmem / memtotal * 100)
Common.text_rows_set(cache, cr, 4, sreclaimable / memtotal * 100)
Common.text_rows_set(cache, 1, cached / memtotal * 100)
Common.text_rows_set(cache, 2, buffers / memtotal * 100)
Common.text_rows_set(cache, 3, shmem / memtotal * 100)
Common.text_rows_set(cache, 4, sreclaimable / memtotal * 100)
Timeseries.update(plot, used_percent)
@ -183,7 +183,7 @@ return function(update_freq)
end
local draw_dynamic = function(cr)
update(cr)
update()
Common.dial_draw_dynamic(mem, cr)
Common.dial_draw_dynamic(swap, cr)

View File

@ -88,10 +88,10 @@ return function(update_freq)
-----------------------------------------------------------------------------
-- main drawing functions
local update = function(cr)
local update = function()
local rx_bits, tx_bits = read_interfaces()
Common.update_rate_timeseries(rx, cr, rx_bits)
Common.update_rate_timeseries(tx, cr, tx_bits)
Common.update_rate_timeseries(rx, rx_bits)
Common.update_rate_timeseries(tx, tx_bits)
end
local draw_static = function(cr)
@ -101,7 +101,7 @@ return function(update_freq)
end
local draw_dynamic = function(cr)
update(cr)
update()
Common.annotated_scale_plot_draw_dynamic(rx, cr)
Common.annotated_scale_plot_draw_dynamic(tx, cr)
end

View File

@ -22,17 +22,17 @@ return function()
{'Total', 'Explicit', 'Outdated', 'Orphaned', 'Local'}
)
local update = function(cr, pacman_stats)
local update = function(pacman_stats)
local stats = __string_match(pacman_stats, '%d+%s+[^%s]+%s+[^%s]+%s+(.*)$')
if stats then
local i = 1
for v in __string_gmatch(stats, '%d+') do
Common.text_rows_set(rows, cr, i, v)
Common.text_rows_set(rows, i, v)
i = i + 1
end
else
for i=1, 5 do
Common.text_rows_set(rows, cr, i, 'N/A')
Common.text_rows_set(rows, i, 'N/A')
end
end
end
@ -43,7 +43,7 @@ return function()
end
local draw_dynamic = function(cr, pacman_stats)
update(cr, pacman_stats)
update(pacman_stats)
Common.text_rows_draw_dynamic(rows, cr)
end

View File

@ -114,10 +114,10 @@ return function(update_freq)
-----------------------------------------------------------------------------
-- main functions
local update = function(cr, is_using_ac)
Common.update_rate_timeseries(pkg0, cr, read_pkg0_joules())
Common.update_rate_timeseries(dram, cr, read_dram_joules())
Common.annotated_scale_plot_set(bat, cr, read_battery_power(is_using_ac))
local update = function(is_using_ac)
Common.update_rate_timeseries(pkg0, read_pkg0_joules())
Common.update_rate_timeseries(dram, read_dram_joules())
Common.annotated_scale_plot_set(bat, read_battery_power(is_using_ac))
end
local draw_static = function(cr)
@ -128,7 +128,7 @@ return function(update_freq)
end
local draw_dynamic = function(cr, is_using_ac)
update(cr, is_using_ac)
update(is_using_ac)
Common.annotated_scale_plot_draw_dynamic(pkg0, cr)
Common.annotated_scale_plot_draw_dynamic(dram, cr)
Common.annotated_scale_plot_draw_dynamic(bat, cr)

View File

@ -134,7 +134,7 @@ return function(update_freq)
-----------------------------------------------------------------------------
-- main functions
local update = function(cr, trigger)
local update = function(trigger)
local conky = Util.conky
local load_sum = 0
@ -147,18 +147,18 @@ return function(update_freq)
for conky_core_id, path in pairs(coretemp_paths) do
local temp = __math_floor(0.001 * Util.read_file(path, nil, '*n'))
Common.text_ring_set(cores[conky_core_id].coretemp, cr, temp)
Common.text_ring_set(cores[conky_core_id].coretemp, temp)
end
-- For some reason this call is slow (querying anything with pstate in
-- general seems slow), but I also don't need to see an update every cycle,
-- hence the trigger
if trigger == 0 then
Common.text_rows_set(cpu_status, cr, 1, CPU.read_hwp(hwp_paths))
Common.text_rows_set(cpu_status, 1, CPU.read_hwp(hwp_paths))
end
Common.text_rows_set(cpu_status, cr, 2, CPU.read_freq())
Common.text_rows_set(cpu_status, 2, CPU.read_freq())
Common.percent_plot_set(total_load, cr, load_sum / ncpus * 100)
Common.percent_plot_set(total_load, load_sum / ncpus * 100)
for r = 1, NUM_ROWS do
local pid = conky(TABLE_CONKY[r].pid, '(%d+)') -- may have leading spaces
@ -187,7 +187,7 @@ return function(update_freq)
end
local draw_dynamic = function(cr, trigger)
update(cr, trigger)
update(trigger)
for i = 1, #cores do
CompoundDial.draw_dynamic(cores[i].loads, cr)

View File

@ -85,10 +85,10 @@ return function(update_freq)
-----------------------------------------------------------------------------
-- main drawing functions
local update = function(cr)
local update = function()
local read_bytes, write_bytes = read_devices()
Common.update_rate_timeseries(reads, cr, read_bytes)
Common.update_rate_timeseries(writes, cr, write_bytes)
Common.update_rate_timeseries(reads, read_bytes)
Common.update_rate_timeseries(writes, write_bytes)
end
local draw_static = function(cr)
@ -98,7 +98,7 @@ return function(update_freq)
end
local draw_dynamic = function(cr)
update(cr)
update()
Common.annotated_scale_plot_draw_dynamic(reads, cr)
Common.annotated_scale_plot_draw_dynamic(writes, cr)
end

View File

@ -33,10 +33,10 @@ return function()
last_update, last_sync = __string_match(pacman_stats, "^%d+%s+([^%s]+)%s+([^%s]+).*")
end
-- TODO this doesn't need to be update every time
Common.text_rows_set(rows, cr, 1, Util.conky('$kernel'))
Common.text_rows_set(rows, cr, 2, Util.conky('$uptime'))
Common.text_rows_set(rows, cr, 3, last_update)
Common.text_rows_set(rows, cr, 4, last_sync)
Common.text_rows_set(rows, 1, Util.conky('$kernel'))
Common.text_rows_set(rows, 2, Util.conky('$uptime'))
Common.text_rows_set(rows, 3, last_update)
Common.text_rows_set(rows, 4, last_sync)
Common.text_rows_draw_dynamic(rows, cr)
end