REF update core
This commit is contained in:
parent
ac01b8f607
commit
208440a6d4
2
core
2
core
|
@ -1 +1 @@
|
||||||
Subproject commit 8fdf42631afd209d076e23e1db1025aafcdcfb62
|
Subproject commit 8f242d7d7618cb2bdcdc3838544e69df5fe92c46
|
|
@ -1,7 +1,7 @@
|
||||||
local M = {}
|
local M = {}
|
||||||
|
|
||||||
local F = require 'geom'
|
local F = require 'geom'
|
||||||
local util = require 'util'
|
local format = require 'format'
|
||||||
local theme = require 'theme'
|
local theme = require 'theme'
|
||||||
local dial = require 'dial'
|
local dial = require 'dial'
|
||||||
local rect = require 'rect'
|
local rect = require 'rect'
|
||||||
|
@ -111,7 +111,7 @@ local _default_plot_config = timeseries.config(
|
||||||
)
|
)
|
||||||
|
|
||||||
local _format_percent_label = function(_)
|
local _format_percent_label = function(_)
|
||||||
return function(z) return util.round_to_string(z * 100)..'%' end
|
return function(z) return string.format('%i%%', z * 100) end
|
||||||
end
|
end
|
||||||
|
|
||||||
local _format_percent_maybe = function(z)
|
local _format_percent_maybe = function(z)
|
||||||
|
@ -272,7 +272,7 @@ end
|
||||||
|
|
||||||
M.converted_y_label_format_generator = function(unit)
|
M.converted_y_label_format_generator = function(unit)
|
||||||
return function(plot_max)
|
return function(plot_max)
|
||||||
local new_prefix, new_max = util.convert_data_val(plot_max)
|
local new_prefix, new_max = format.convert_data_val(plot_max)
|
||||||
local conversion_factor = plot_max / new_max
|
local conversion_factor = plot_max / new_max
|
||||||
local fmt = M.y_label_format_string(new_max, new_prefix..unit..'/s')
|
local fmt = M.y_label_format_string(new_max, new_prefix..unit..'/s')
|
||||||
return function(bytes)
|
return function(bytes)
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
local line = require 'line'
|
local line = require 'line'
|
||||||
local util = require 'util'
|
local i_o = require 'i_o'
|
||||||
local common = require 'common'
|
local common = require 'common'
|
||||||
local geometry = require 'geometry'
|
local geometry = require 'geometry'
|
||||||
|
|
||||||
|
@ -65,11 +65,11 @@ return function()
|
||||||
|
|
||||||
local update = function(trigger)
|
local update = function(trigger)
|
||||||
if trigger == 0 then
|
if trigger == 0 then
|
||||||
local smart_pid = util.execute_cmd('pidof smartd', nil, '*n')
|
local smart_pid = i_o.execute_cmd('pidof smartd', nil, '*n')
|
||||||
common.text_row_set(smart, (smart_pid == '') and 'Error' or 'Running')
|
common.text_row_set(smart, (smart_pid == '') and 'Error' or 'Running')
|
||||||
|
|
||||||
for i = 1, FS_NUM do
|
for i = 1, FS_NUM do
|
||||||
local percent = util.conky_numeric(CONKY_USED_PERC[i])
|
local percent = i_o.conky_numeric(CONKY_USED_PERC[i])
|
||||||
common.compound_bar_set(fs, i, percent * 0.01)
|
common.compound_bar_set(fs, i, percent * 0.01)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
local text = require 'text'
|
local text = require 'text'
|
||||||
local line = require 'line'
|
local line = require 'line'
|
||||||
local util = require 'util'
|
local i_o = require 'i_o'
|
||||||
local common = require 'common'
|
local common = require 'common'
|
||||||
local geometry = require 'geometry'
|
local geometry = require 'geometry'
|
||||||
|
|
||||||
|
@ -154,8 +154,8 @@ return function(update_freq)
|
||||||
end
|
end
|
||||||
|
|
||||||
local update = function()
|
local update = function()
|
||||||
if util.read_file(GPU_BUS_CTRL, nil, '*l') == 'on' then
|
if i_o.read_file(GPU_BUS_CTRL, nil, '*l') == 'on' then
|
||||||
local nvidia_settings_glob = util.execute_cmd(NV_QUERY)
|
local nvidia_settings_glob = i_o.execute_cmd(NV_QUERY)
|
||||||
if nvidia_settings_glob == '' then
|
if nvidia_settings_glob == '' then
|
||||||
text.set(status.value, 'Error')
|
text.set(status.value, 'Error')
|
||||||
nvidia_off()
|
nvidia_off()
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
local timeseries = require 'timeseries'
|
local timeseries = require 'timeseries'
|
||||||
local texttable = require 'texttable'
|
local texttable = require 'texttable'
|
||||||
local util = require 'util'
|
local i_o = require 'i_o'
|
||||||
local common = require 'common'
|
local common = require 'common'
|
||||||
local geometry = require 'geometry'
|
local geometry = require 'geometry'
|
||||||
local pure = require 'pure'
|
local pure = require 'pure'
|
||||||
|
@ -41,7 +41,7 @@ return function(update_freq)
|
||||||
-- mem consumption dial
|
-- mem consumption dial
|
||||||
|
|
||||||
local get_meminfo_field = function(field)
|
local get_meminfo_field = function(field)
|
||||||
return tonumber(util.read_file('/proc/meminfo', field..':%s+(%d+)'))
|
return tonumber(i_o.read_file('/proc/meminfo', field..':%s+(%d+)'))
|
||||||
end
|
end
|
||||||
|
|
||||||
local memtotal = get_meminfo_field('MemTotal')
|
local memtotal = get_meminfo_field('MemTotal')
|
||||||
|
@ -134,16 +134,14 @@ return function(update_freq)
|
||||||
-- main functions
|
-- main functions
|
||||||
|
|
||||||
local update = function()
|
local update = function()
|
||||||
local conky = util.conky
|
|
||||||
-- see manpage for free command for formulas
|
-- see manpage for free command for formulas
|
||||||
|
|
||||||
local memfree,
|
local memfree,
|
||||||
buffers,
|
buffers,
|
||||||
cached,
|
cached,
|
||||||
swapfree,
|
swapfree,
|
||||||
shmem,
|
shmem,
|
||||||
sreclaimable
|
sreclaimable
|
||||||
= __string_match(util.read_file('/proc/meminfo'), MEMINFO_REGEX)
|
= __string_match(i_o.read_file('/proc/meminfo'), MEMINFO_REGEX)
|
||||||
|
|
||||||
local used_percent =
|
local used_percent =
|
||||||
(memtotal -
|
(memtotal -
|
||||||
|
@ -163,9 +161,9 @@ return function(update_freq)
|
||||||
timeseries.update(plot, used_percent)
|
timeseries.update(plot, used_percent)
|
||||||
|
|
||||||
for r = 1, NUM_ROWS do
|
for r = 1, NUM_ROWS do
|
||||||
texttable.set(tbl, 1, r, conky(TABLE_CONKY[r].comm, '(%S+)'))
|
texttable.set(tbl, 1, r, i_o.conky(TABLE_CONKY[r].comm, '(%S+)'))
|
||||||
texttable.set(tbl, 2, r, conky(TABLE_CONKY[r].pid))
|
texttable.set(tbl, 2, r, i_o.conky(TABLE_CONKY[r].pid))
|
||||||
texttable.set(tbl, 3, r, conky(TABLE_CONKY[r].mem))
|
texttable.set(tbl, 3, r, i_o.conky(TABLE_CONKY[r].mem))
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
local util = require 'util'
|
local format = require 'format'
|
||||||
|
local i_o = require 'i_o'
|
||||||
local common = require 'common'
|
local common = require 'common'
|
||||||
local geometry = require 'geometry'
|
local geometry = require 'geometry'
|
||||||
local pure = require 'pure'
|
local pure = require 'pure'
|
||||||
|
@ -8,7 +9,7 @@ return function(update_freq)
|
||||||
local PLOT_HEIGHT = 56
|
local PLOT_HEIGHT = 56
|
||||||
|
|
||||||
local get_interfaces = function()
|
local get_interfaces = function()
|
||||||
local s = util.execute_cmd('realpath /sys/class/net/* | grep -v virtual')
|
local s = i_o.execute_cmd('realpath /sys/class/net/* | grep -v virtual')
|
||||||
local interfaces = {}
|
local interfaces = {}
|
||||||
for iface in string.gmatch(s, '/([^/\n]+)\n') do
|
for iface in string.gmatch(s, '/([^/\n]+)\n') do
|
||||||
interfaces[#interfaces + 1] = iface
|
interfaces[#interfaces + 1] = iface
|
||||||
|
@ -27,7 +28,7 @@ return function(update_freq)
|
||||||
)
|
)
|
||||||
|
|
||||||
local get_bits = function(path)
|
local get_bits = function(path)
|
||||||
return util.read_file(path, nil, '*n') * 8
|
return i_o.read_file(path, nil, '*n') * 8
|
||||||
end
|
end
|
||||||
|
|
||||||
local read_interfaces = function()
|
local read_interfaces = function()
|
||||||
|
@ -44,8 +45,8 @@ return function(update_freq)
|
||||||
local init_rx_bits, init_tx_bits = read_interfaces()
|
local init_rx_bits, init_tx_bits = read_interfaces()
|
||||||
|
|
||||||
local value_format_function = function(bits)
|
local value_format_function = function(bits)
|
||||||
local unit, value = util.convert_data_val(bits)
|
local unit, value = format.convert_data_val(bits)
|
||||||
return util.precision_round_to_string(value, 3)..' '..unit..'b/s'
|
return format.precision_round_to_string(value, 3)..' '..unit..'b/s'
|
||||||
end
|
end
|
||||||
|
|
||||||
local make_plot = function(y, label, init)
|
local make_plot = function(y, label, init)
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
local util = require 'util'
|
local format = require 'format'
|
||||||
|
local i_o = require 'i_o'
|
||||||
local common = require 'common'
|
local common = require 'common'
|
||||||
local geometry = require 'geometry'
|
local geometry = require 'geometry'
|
||||||
|
|
||||||
|
@ -13,7 +14,7 @@ return function(update_freq)
|
||||||
local BAT_VOLTAGE_PATH = '/sys/class/power_supply/BAT0/voltage_now'
|
local BAT_VOLTAGE_PATH = '/sys/class/power_supply/BAT0/voltage_now'
|
||||||
|
|
||||||
local read_milli = function(path)
|
local read_milli = function(path)
|
||||||
return util.read_file(path, nil, '*n') * 0.000001
|
return i_o.read_file(path, nil, '*n') * 0.000001
|
||||||
end
|
end
|
||||||
|
|
||||||
local read_pkg0_joules = function()
|
local read_pkg0_joules = function()
|
||||||
|
@ -46,7 +47,7 @@ return function(update_freq)
|
||||||
end
|
end
|
||||||
|
|
||||||
local format_rapl = function(watts)
|
local format_rapl = function(watts)
|
||||||
return util.precision_round_to_string(watts, 3)..' W'
|
return format.precision_round_to_string(watts, 3)..' W'
|
||||||
end
|
end
|
||||||
|
|
||||||
local make_rate_plot = function(y, label, init)
|
local make_rate_plot = function(y, label, init)
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
local compounddial = require 'compounddial'
|
local compounddial = require 'compounddial'
|
||||||
local line = require 'line'
|
local line = require 'line'
|
||||||
local texttable = require 'texttable'
|
local texttable = require 'texttable'
|
||||||
local util = require 'util'
|
local i_o = require 'i_o'
|
||||||
local common = require 'common'
|
local common = require 'common'
|
||||||
local geometry = require 'geometry'
|
local geometry = require 'geometry'
|
||||||
local cpu = require 'sys'
|
local cpu = require 'sys'
|
||||||
|
@ -135,7 +135,6 @@ return function(update_freq)
|
||||||
-- main functions
|
-- main functions
|
||||||
|
|
||||||
local update = function(trigger)
|
local update = function(trigger)
|
||||||
local conky = util.conky
|
|
||||||
local load_sum = 0
|
local load_sum = 0
|
||||||
|
|
||||||
cpu_loads = cpu.read_cpu_loads(cpu_loads)
|
cpu_loads = cpu.read_cpu_loads(cpu_loads)
|
||||||
|
@ -146,7 +145,7 @@ return function(update_freq)
|
||||||
end
|
end
|
||||||
|
|
||||||
for conky_core_id, path in pairs(coretemp_paths) do
|
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 * i_o.read_file(path, nil, '*n'))
|
||||||
common.text_circle_set(cores[conky_core_id].coretemp, temp)
|
common.text_circle_set(cores[conky_core_id].coretemp, temp)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -161,11 +160,11 @@ return function(update_freq)
|
||||||
common.tagged_percent_timeseries_set(total_load, load_sum / ncpus * 100)
|
common.tagged_percent_timeseries_set(total_load, load_sum / ncpus * 100)
|
||||||
|
|
||||||
for r = 1, NUM_ROWS do
|
for r = 1, NUM_ROWS do
|
||||||
local pid = conky(TABLE_CONKY[r].pid, '(%d+)') -- may have leading spaces
|
local pid = i_o.conky(TABLE_CONKY[r].pid, '(%d+)') -- may have leading spaces
|
||||||
if pid ~= '' then
|
if pid ~= '' then
|
||||||
texttable.set(tbl, 1, r, util.read_file('/proc/'..pid..'/comm', '(%C+)'))
|
texttable.set(tbl, 1, r, i_o.read_file('/proc/'..pid..'/comm', '(%C+)'))
|
||||||
texttable.set(tbl, 2, r, pid)
|
texttable.set(tbl, 2, r, pid)
|
||||||
texttable.set(tbl, 3, r, conky(TABLE_CONKY[r].cpu))
|
texttable.set(tbl, 3, r, i_o.conky(TABLE_CONKY[r].cpu))
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
local util = require 'util'
|
local i_o = require 'i_o'
|
||||||
|
local format = require 'format'
|
||||||
local common = require 'common'
|
local common = require 'common'
|
||||||
local geometry = require 'geometry'
|
local geometry = require 'geometry'
|
||||||
local pure = require 'pure'
|
local pure = require 'pure'
|
||||||
|
@ -28,7 +29,7 @@ return function(update_freq)
|
||||||
local read_bytes = 0
|
local read_bytes = 0
|
||||||
local write_bytes = 0
|
local write_bytes = 0
|
||||||
for _, path in pairs(DEVICE_PATHS) do
|
for _, path in pairs(DEVICE_PATHS) do
|
||||||
local r, w = __string_match(util.read_file(path), RW_REGEX)
|
local r, w = __string_match(i_o.read_file(path), RW_REGEX)
|
||||||
read_bytes = read_bytes + __tonumber(r)
|
read_bytes = read_bytes + __tonumber(r)
|
||||||
write_bytes = write_bytes + __tonumber(w)
|
write_bytes = write_bytes + __tonumber(w)
|
||||||
end
|
end
|
||||||
|
@ -38,8 +39,8 @@ return function(update_freq)
|
||||||
local init_read_bytes, init_write_bytes = read_devices()
|
local init_read_bytes, init_write_bytes = read_devices()
|
||||||
|
|
||||||
local format_value_function = function(bps)
|
local format_value_function = function(bps)
|
||||||
local unit, value = util.convert_data_val(bps)
|
local unit, value = format.convert_data_val(bps)
|
||||||
return util.precision_round_to_string(value, 3)..' '..unit..'B/s'
|
return format.precision_round_to_string(value, 3)..' '..unit..'B/s'
|
||||||
end
|
end
|
||||||
|
|
||||||
local make_plot = function(y, label, init)
|
local make_plot = function(y, label, init)
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
local util = require 'util'
|
local i_o = require 'i_o'
|
||||||
local common = require 'common'
|
local common = require 'common'
|
||||||
local geometry = require 'geometry'
|
local geometry = require 'geometry'
|
||||||
|
|
||||||
|
@ -28,8 +28,8 @@ return function()
|
||||||
last_update, last_sync = __string_match(pacman_stats, "^%d+%s+([^%s]+)%s+([^%s]+).*")
|
last_update, last_sync = __string_match(pacman_stats, "^%d+%s+([^%s]+)%s+([^%s]+).*")
|
||||||
end
|
end
|
||||||
-- TODO this doesn't need to be update every time
|
-- TODO this doesn't need to be update every time
|
||||||
common.text_rows_set(rows, 1, util.conky('$kernel'))
|
common.text_rows_set(rows, 1, i_o.conky('$kernel'))
|
||||||
common.text_rows_set(rows, 2, util.conky('$uptime'))
|
common.text_rows_set(rows, 2, i_o.conky('$uptime'))
|
||||||
common.text_rows_set(rows, 3, last_update)
|
common.text_rows_set(rows, 3, last_update)
|
||||||
common.text_rows_set(rows, 4, last_sync)
|
common.text_rows_set(rows, 4, last_sync)
|
||||||
end
|
end
|
||||||
|
|
6
main.lua
6
main.lua
|
@ -16,7 +16,7 @@ package.path = ABS_PATH..'?.lua;'..
|
||||||
ABS_PATH..'core/widget/rect/?.lua;'..
|
ABS_PATH..'core/widget/rect/?.lua;'..
|
||||||
ABS_PATH..'core/widget/poly/?.lua;'
|
ABS_PATH..'core/widget/poly/?.lua;'
|
||||||
|
|
||||||
local util = require 'util'
|
local i_o = require 'i_o'
|
||||||
local system = require 'system'
|
local system = require 'system'
|
||||||
local network = require 'network'
|
local network = require 'network'
|
||||||
local processor = require 'processor'
|
local processor = require 'processor'
|
||||||
|
@ -31,7 +31,7 @@ local static = require 'static'
|
||||||
local using_ac = function()
|
local using_ac = function()
|
||||||
-- for some reason it is much more efficient to test if the battery
|
-- for some reason it is much more efficient to test if the battery
|
||||||
-- is off than if the ac is on
|
-- is off than if the ac is on
|
||||||
return util.read_file('/sys/class/power_supply/BAT0/status', nil, '*l') ~= 'Discharging'
|
return i_o.read_file('/sys/class/power_supply/BAT0/status', nil, '*l') ~= 'Discharging'
|
||||||
end
|
end
|
||||||
|
|
||||||
local draw_dynamic
|
local draw_dynamic
|
||||||
|
@ -65,7 +65,7 @@ function conky_start(update_interval)
|
||||||
|
|
||||||
-- update dynamic components
|
-- update dynamic components
|
||||||
local t1 = _updates % (update_freq * 10)
|
local t1 = _updates % (update_freq * 10)
|
||||||
local pacman_stats = util.read_file(STATS_FILE)
|
local pacman_stats = i_o.read_file(STATS_FILE)
|
||||||
local is_using_ac = using_ac()
|
local is_using_ac = using_ac()
|
||||||
|
|
||||||
sys.update(pacman_stats)
|
sys.update(pacman_stats)
|
||||||
|
|
Loading…
Reference in New Issue