diff --git a/core b/core index f042714..b3c5588 160000 --- a/core +++ b/core @@ -1 +1 @@ -Subproject commit f04271472373e5ae290108dc27742fef5f32def5 +Subproject commit b3c558845da08e92febc612260d710f06c2c7b9a diff --git a/drawing/common.lua b/drawing/common.lua index 255da54..81d43cd 100644 --- a/drawing/common.lua +++ b/drawing/common.lua @@ -1,7 +1,7 @@ local M = {} local F = require 'primitive' -local Util = require 'Util' +local util = require 'util' local theme = require 'theme' local dial = require 'dial' local rect = require 'rect' @@ -139,7 +139,7 @@ local default_plot_config = timeseries.config( M.percent_label_config = timeseries.label_config( theme.INACTIVE_TEXT_FG, label_font_spec, - function(_) return function(z) return Util.round_to_string(z * 100)..'%' end end + function(_) return function(z) return util.round_to_string(z * 100)..'%' end end ) M.initthemedLabelPlot = function(x, y, w, h, label_config, update_freq) @@ -224,7 +224,7 @@ end M.converted_y_label_format_generator = function(unit) return function(plot_max) - local new_prefix, new_max = Util.convert_data_val(plot_max) + local new_prefix, new_max = util.convert_data_val(plot_max) local conversion_factor = plot_max / new_max local fmt = M.y_label_format_string(new_max, new_prefix..unit..'/s') return function(bytes) diff --git a/drawing/filesystem.lua b/drawing/filesystem.lua index 9d30d1f..404ce72 100644 --- a/drawing/filesystem.lua +++ b/drawing/filesystem.lua @@ -1,5 +1,5 @@ local line = require 'line' -local Util = require 'Util' +local util = require 'util' local common = require 'common' local geometry = require 'geometry' @@ -65,11 +65,11 @@ return function() local update = function(trigger) if trigger == 0 then - local smart_pid = Util.execute_cmd('pidof smartd', nil, '*n') + local smart_pid = util.execute_cmd('pidof smartd', nil, '*n') 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]) + local percent = util.conky_numeric(CONKY_USED_PERC[i]) common.compound_bar_set(fs, i, percent * 0.01) end end diff --git a/drawing/graphics.lua b/drawing/graphics.lua index 9d5c262..53edfe8 100644 --- a/drawing/graphics.lua +++ b/drawing/graphics.lua @@ -1,6 +1,6 @@ local text = require 'text' local line = require 'line' -local Util = require 'Util' +local util = require 'util' local common = require 'common' local geometry = require 'geometry' @@ -109,19 +109,19 @@ return function(update_freq) end local GPU_UTIL_Y = SEP_Y3 + SEPARATOR_SPACING - local gpu_util = build_plot(GPU_UTIL_Y, 'GPU Utilization') + local gpu_util = build_plot(GPU_UTIL_Y, 'GPU utilization') ----------------------------------------------------------------------------- -- gpu memory consumption plot local MEM_UTIL_Y = GPU_UTIL_Y + PLOT_HEIGHT + PLOT_SEC_BREAK * 2 - local mem_util = build_plot(MEM_UTIL_Y, 'memory Utilization') + local mem_util = build_plot(MEM_UTIL_Y, 'memory utilization') ----------------------------------------------------------------------------- -- gpu video utilization plot local VID_UTIL_Y = MEM_UTIL_Y + PLOT_HEIGHT + PLOT_SEC_BREAK * 2 - local vid_util = build_plot(VID_UTIL_Y, 'Video Utilization') + local vid_util = build_plot(VID_UTIL_Y, 'Video utilization') ----------------------------------------------------------------------------- -- update function @@ -139,7 +139,7 @@ return function(update_freq) ' -q TotalDedicatedGPUmemory'.. ' -q ThermalSensorReading'.. ' -q [gpu:0]/GPUCurrentClockFreqs'.. - ' -q [gpu:0]/GPUUtilization' + ' -q [gpu:0]/GPUutilization' local NV_REGEX = '(%d+)\n'.. '(%d+)\n'.. @@ -159,8 +159,8 @@ return function(update_freq) end local update = function() - if Util.read_file(GPU_BUS_CTRL, nil, '*l') == 'on' then - local nvidia_settings_glob = Util.execute_cmd(NV_QUERY) + 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, 'Error') nvidia_off() diff --git a/drawing/memory.lua b/drawing/memory.lua index 05f3d21..7240d78 100644 --- a/drawing/memory.lua +++ b/drawing/memory.lua @@ -1,6 +1,6 @@ local timeseries = require 'timeseries' local texttable = require 'texttable' -local Util = require 'Util' +local util = require 'util' local common = require 'common' local geometry = require 'geometry' local func = require 'func' @@ -41,7 +41,7 @@ return function(update_freq) -- mem consumption dial local get_meminfo_field = function(field) - return tonumber(Util.read_file('/proc/meminfo', field..':%s+(%d+)')) + return tonumber(util.read_file('/proc/meminfo', field..':%s+(%d+)')) end local memtotal = get_meminfo_field('MemTotal') @@ -135,7 +135,7 @@ return function(update_freq) -- main functions local update = function() - local conky = Util.conky + local conky = util.conky -- see manpage for free command for formulas local memfree, @@ -144,7 +144,7 @@ return function(update_freq) swapfree, shmem, sreclaimable - = __string_match(Util.read_file('/proc/meminfo'), MEMINFO_REGEX) + = __string_match(util.read_file('/proc/meminfo'), MEMINFO_REGEX) local used_percent = (memtotal - diff --git a/drawing/network.lua b/drawing/network.lua index 194384c..5620979 100644 --- a/drawing/network.lua +++ b/drawing/network.lua @@ -1,4 +1,4 @@ -local Util = require 'Util' +local util = require 'util' local common = require 'common' local geometry = require 'geometry' local func = require 'func' @@ -8,7 +8,7 @@ return function(update_freq) local PLOT_HEIGHT = 56 local get_interfaces = function() - local s = Util.execute_cmd('realpath /sys/class/net/* | grep -v virtual') + local s = util.execute_cmd('realpath /sys/class/net/* | grep -v virtual') local interfaces = {} for iface in string.gmatch(s, '/([^/\n]+)\n') do interfaces[#interfaces + 1] = iface @@ -27,7 +27,7 @@ return function(update_freq) ) local get_bits = function(path) - return Util.read_file(path, nil, '*n') * 8 + return util.read_file(path, nil, '*n') * 8 end local read_interfaces = function() @@ -44,8 +44,8 @@ return function(update_freq) local init_rx_bits, init_tx_bits = read_interfaces() local value_format_function = function(bits) - local unit, value = Util.convert_data_val(bits) - return Util.precision_round_to_string(value, 3)..' '..unit..'b/s' + local unit, value = util.convert_data_val(bits) + return util.precision_round_to_string(value, 3)..' '..unit..'b/s' end local build_plot = function(y, label, init) diff --git a/drawing/power.lua b/drawing/power.lua index 8f4b478..19dbdd8 100644 --- a/drawing/power.lua +++ b/drawing/power.lua @@ -1,4 +1,4 @@ -local Util = require 'Util' +local util = require 'util' local common = require 'common' local geometry = require 'geometry' @@ -13,7 +13,7 @@ return function(update_freq) local BAT_VOLTAGE_PATH = '/sys/class/power_supply/BAT0/voltage_now' local read_milli = function(path) - return Util.read_file(path, nil, '*n') * 0.000001 + return util.read_file(path, nil, '*n') * 0.000001 end local read_pkg0_joules = function() @@ -46,7 +46,7 @@ return function(update_freq) end local format_rapl = function(watts) - return Util.precision_round_to_string(watts, 3)..' W' + return util.precision_round_to_string(watts, 3)..' W' end local build_rate_plot = function(y, label, init) diff --git a/drawing/processor.lua b/drawing/processor.lua index 2f63f21..756dba8 100644 --- a/drawing/processor.lua +++ b/drawing/processor.lua @@ -1,10 +1,10 @@ local compounddial = require 'compounddial' local line = require 'line' local texttable = require 'texttable' -local Util = require 'Util' +local util = require 'util' local common = require 'common' local geometry = require 'geometry' -local CPU = require 'CPU' +local cpu = require 'cpu' local func = require 'func' local __math_floor = math.floor @@ -34,13 +34,13 @@ return function(update_freq) ----------------------------------------------------------------------------- -- cores (loads and temps) - local cpu_loads = CPU.init_cpu_loads() - local ncpus = CPU.get_cpu_number() - local ncores = CPU.get_core_number() + local cpu_loads = cpu.init_cpu_loads() + local ncpus = cpu.get_cpu_number() + local ncores = cpu.get_core_number() local nthreads = ncpus / ncores - local hwp_paths = CPU.get_hwp_paths() - local coretemp_paths = CPU.get_coretemp_paths() - CPU.read_cpu_loads(cpu_loads) -- prime load matrix by side effect + local hwp_paths = cpu.get_hwp_paths() + local coretemp_paths = cpu.get_coretemp_paths() + cpu.read_cpu_loads(cpu_loads) -- prime load matrix by side effect local cores = {} @@ -128,17 +128,17 @@ return function(update_freq) geometry.SECTION_WIDTH, TABLE_HEIGHT, NUM_ROWS, - {'Name', 'PID', 'CPU (%)'} + {'Name', 'PID', 'cpu (%)'} ) ----------------------------------------------------------------------------- -- main functions local update = function(trigger) - local conky = Util.conky + local conky = util.conky local load_sum = 0 - cpu_loads = CPU.read_cpu_loads(cpu_loads) + cpu_loads = cpu.read_cpu_loads(cpu_loads) for _, load_data in pairs(cpu_loads) do local cur = load_data.percent_active load_sum = load_sum + cur @@ -146,7 +146,7 @@ return function(update_freq) end for conky_core_id, path in pairs(coretemp_paths) do - local temp = __math_floor(0.001 * Util.read_file(path, nil, '*n')) + local temp = __math_floor(0.001 * util.read_file(path, nil, '*n')) common.text_ring_set(cores[conky_core_id].coretemp, temp) end @@ -154,16 +154,16 @@ return function(update_freq) -- 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, 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, 2, CPU.read_freq()) + common.text_rows_set(cpu_status, 2, cpu.read_freq()) 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 if pid ~= '' then - texttable.set(tbl, 1, r, Util.read_file('/proc/'..pid..'/comm', '(%C+)')) + texttable.set(tbl, 1, r, util.read_file('/proc/'..pid..'/comm', '(%C+)')) texttable.set(tbl, 2, r, pid) texttable.set(tbl, 3, r, conky(TABLE_CONKY[r].cpu)) end diff --git a/drawing/readwrite.lua b/drawing/readwrite.lua index bfaa1e9..5d00cdc 100644 --- a/drawing/readwrite.lua +++ b/drawing/readwrite.lua @@ -1,4 +1,4 @@ -local Util = require 'Util' +local util = require 'util' local common = require 'common' local geometry = require 'geometry' local func = require 'func' @@ -28,7 +28,7 @@ return function(update_freq) local read_bytes = 0 local write_bytes = 0 for _, path in pairs(DEVICE_PATHS) do - local r, w = __string_match(Util.read_file(path), RW_REGEX) + local r, w = __string_match(util.read_file(path), RW_REGEX) read_bytes = read_bytes + __tonumber(r) write_bytes = write_bytes + __tonumber(w) end @@ -38,8 +38,8 @@ return function(update_freq) local init_read_bytes, init_write_bytes = read_devices() local format_value_function = function(bps) - local unit, value = Util.convert_data_val(bps) - return Util.precision_round_to_string(value, 3)..' '..unit..'B/s' + local unit, value = util.convert_data_val(bps) + return util.precision_round_to_string(value, 3)..' '..unit..'B/s' end local build_plot = function(y, label, init) diff --git a/drawing/system.lua b/drawing/system.lua index db7725d..15a9c15 100644 --- a/drawing/system.lua +++ b/drawing/system.lua @@ -1,4 +1,4 @@ -local Util = require 'Util' +local util = require 'util' local common = require 'common' local geometry = require 'geometry' @@ -28,8 +28,8 @@ 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, 1, Util.conky('$kernel')) - common.text_rows_set(rows, 2, Util.conky('$uptime')) + 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) end diff --git a/main.lua b/main.lua index 929c3be..6806527 100644 --- a/main.lua +++ b/main.lua @@ -16,7 +16,7 @@ package.path = ABS_PATH..'?.lua;'.. ABS_PATH..'core/widget/rect/?.lua;'.. ABS_PATH..'core/widget/poly/?.lua;' -local Util = require 'Util' +local util = require 'util' local system = require 'system' local network = require 'network' local processor = require 'processor' @@ -31,7 +31,7 @@ local static = require 'static' local using_ac = function() -- for some reason it is much more efficient to test if the battery -- is off than if the ac is on - return Util.read_file('/sys/class/power_supply/BAT0/status', nil, '*l') ~= 'Discharging' + return util.read_file('/sys/class/power_supply/BAT0/status', nil, '*l') ~= 'Discharging' end local draw_dynamic @@ -65,7 +65,7 @@ function conky_start(update_interval) -- update dynamic components local t1 = _updates % (update_freq * 10) - local pacman_stats = Util.read_file(STATS_FILE) + local pacman_stats = util.read_file(STATS_FILE) local is_using_ac = using_ac() sys.update(pacman_stats)