REF rename all modules to be lowercase like they are supposed to be in lua

This commit is contained in:
Nathan Dwarshuis 2021-07-29 22:18:29 -04:00
parent 12da82ac49
commit f96f587e11
14 changed files with 295 additions and 295 deletions

View File

@ -2,7 +2,7 @@ local M = {}
local F = require 'Fundamental'
local Util = require 'Util'
local Theme = require 'Theme'
local theme = require 'theme'
local Dial = require 'Dial'
local Rect = require 'Rect'
local FillRect = require 'FillRect'
@ -69,8 +69,8 @@ local _text_row_style = function(x_align, color)
return Text.style(normal_font_spec, color, x_align, 'center')
end
local left_text_style = _text_row_style('left', Theme.INACTIVE_TEXT_FG)
local right_text_style = _text_row_style('right', Theme.PRIMARY_FG)
local left_text_style = _text_row_style('left', theme.INACTIVE_TEXT_FG)
local right_text_style = _text_row_style('right', theme.PRIMARY_FG)
local _bare_text = function(pt, text, style)
return Text.build_plain(pt, text, style)
@ -96,7 +96,7 @@ M.Header = function(x, y, w, text)
text,
Text.style(
make_font_spec(FONT, HEADER_FONT_SIZE, true),
Theme.HEADER_FG,
theme.HEADER_FG,
'left',
'top'
)
@ -107,7 +107,7 @@ M.Header = function(x, y, w, text)
F.make_point(x + w, underline_y),
Line.config(
s.line(HEADER_UNDERLINE_THICKNESS, HEADER_UNDERLINE_CAP),
Theme.HEADER_FG,
theme.HEADER_FG,
true
)
)
@ -125,24 +125,24 @@ end
local default_grid_config = Timeseries.grid_config(
PLOT_GRID_X_N,
PLOT_GRID_Y_N,
Theme.PLOT_GRID_FG
theme.PLOT_GRID_FG
)
local default_plot_config = Timeseries.config(
PLOT_NUM_POINTS,
Theme.PLOT_OUTLINE_FG,
Theme.PLOT_FILL_BORDER_PRIMARY,
Theme.PLOT_FILL_BG_PRIMARY,
theme.PLOT_OUTLINE_FG,
theme.PLOT_FILL_BORDER_PRIMARY,
theme.PLOT_FILL_BG_PRIMARY,
default_grid_config
)
M.percent_label_config = Timeseries.label_config(
Theme.INACTIVE_TEXT_FG,
theme.INACTIVE_TEXT_FG,
label_font_spec,
function(_) return function(z) return Util.round_to_string(z * 100)..'%' end end
)
M.initThemedLabelPlot = function(x, y, w, h, label_config, update_freq)
M.initthemedLabelPlot = function(x, y, w, h, label_config, update_freq)
return Timeseries.build(
F.make_box(x, y, w, h),
update_freq,
@ -162,9 +162,9 @@ M.initPercentPlot_formatted = function(x, y, w, h, spacing, label, update_freq,
nil,
right_text_style,
format,
ThresholdText.style(Theme.CRITICAL_FG, 80)
ThresholdText.style(theme.CRITICAL_FG, 80)
),
plot = M.initThemedLabelPlot(
plot = M.initthemedLabelPlot(
x,
y + spacing,
w,
@ -237,13 +237,13 @@ M.base_2_scale_data = function(m)
return ScaledTimeseries.scaling_parameters(2, m, 0.9)
end
M.initThemedScalePlot = function(x, y, w, h, f, min_domain, update_freq)
M.initthemedScalePlot = function(x, y, w, h, f, min_domain, update_freq)
return ScaledTimeseries.build(
F.make_box(x, y, w, h),
update_freq,
default_plot_config,
Timeseries.label_config(
Theme.INACTIVE_TEXT_FG,
theme.INACTIVE_TEXT_FG,
label_font_spec,
f
),
@ -264,7 +264,7 @@ M.initLabeledScalePlot = function(x, y, w, h, format_fun, label_fun, spacing,
right_text_style,
format_fun
),
plot = M.initThemedScalePlot(x, y + spacing, w, h, label_fun, min_domain, update_freq),
plot = M.initthemedScalePlot(x, y + spacing, w, h, label_fun, min_domain, update_freq),
}
end
@ -315,7 +315,7 @@ M.build_rate_timeseries = function(x, y, w, h, format_fun, label_fun, spacing,
right_text_style,
format_fun
),
plot = M.initThemedScalePlot(x, y + spacing, w, h, label_fun, min_domain, update_freq),
plot = M.initthemedScalePlot(x, y + spacing, w, h, label_fun, min_domain, update_freq),
prev_value = init,
derive = build_differential(update_freq),
}
@ -347,7 +347,7 @@ end
M.initRing = function(x, y, r)
return Arc.build(
F.make_semicircle(x, y, r, 0, 360),
Arc.config(s.line(ARC_WIDTH, CAIRO_LINE_CAP_BUTT), Theme.BORDER_FG)
Arc.config(s.line(ARC_WIDTH, CAIRO_LINE_CAP_BUTT), theme.BORDER_FG)
)
end
@ -362,12 +362,12 @@ M.initTextRing = function(x, y, r, fmt, limit)
0,
Text.style(
normal_font_spec,
Theme.PRIMARY_FG,
theme.PRIMARY_FG,
'center',
'center'
),
fmt,
ThresholdText.style(Theme.CRITICAL_FG, limit)
ThresholdText.style(theme.CRITICAL_FG, limit)
),
}
end
@ -389,8 +389,8 @@ end
local threshold_indicator = function(threshold)
return F.threshold_style(
Theme.INDICATOR_FG_PRIMARY,
Theme.INDICATOR_FG_CRITICAL,
theme.INDICATOR_FG_PRIMARY,
theme.INDICATOR_FG_CRITICAL,
threshold
)
end
@ -399,7 +399,7 @@ M.dial = function(x, y, radius, thickness, threshold, format)
return {
dial = Dial.build(
F.make_semicircle(x, y, radius, DIAL_THETA0, DIAL_THETA1),
Arc.config(s.line(thickness, CAIRO_LINE_CAP_BUTT), Theme.INDICATOR_BG),
Arc.config(s.line(thickness, CAIRO_LINE_CAP_BUTT), theme.INDICATOR_BG),
threshold_indicator(threshold)
),
text_ring = M.initTextRing(x, y, radius - thickness / 2 - 2, format, threshold),
@ -428,7 +428,7 @@ M.compound_dial = function(x, y, outer_radius, inner_radius, thickness,
threshold, num_dials)
return CompoundDial.build(
F.make_semicircle(x, y, outer_radius, DIAL_THETA0, DIAL_THETA1),
Arc.config(s.line(thickness, CAIRO_LINE_CAP_BUTT), Theme.INDICATOR_BG),
Arc.config(s.line(thickness, CAIRO_LINE_CAP_BUTT), theme.INDICATOR_BG),
threshold_indicator(threshold),
inner_radius,
num_dials
@ -452,7 +452,7 @@ M.compound_bar = function(x, y, w, pad, labels, spacing, thickness, threshold)
w - pad,
Line.config(
s.line(thickness, CAIRO_LINE_CAP_BUTT),
Theme.INDICATOR_BG,
theme.INDICATOR_BG,
true
),
threshold_indicator(threshold),
@ -485,7 +485,7 @@ M.initSeparator = function(x, y, w)
F.make_point(x + w, y),
Line.config(
s.line(SEPARATOR_THICKNESS, CAIRO_LINE_CAP_BUTT),
Theme.BORDER_FG,
theme.BORDER_FG,
true
)
)
@ -524,12 +524,12 @@ M.initTextRowCrit = function(x, y, w, label, append_end, limit)
nil,
Text.style(
normal_font_spec,
Theme.PRIMARY_FG,
theme.PRIMARY_FG,
'right',
'center'
),
append_end,
ThresholdText.style(Theme.CRITICAL_FG, limit)
ThresholdText.style(theme.CRITICAL_FG, limit)
)
}
end
@ -587,7 +587,7 @@ M.initTextRows_formatted = function(x, y, w, spacing, labels, format)
w,
spacing,
labels,
Theme.PRIMARY_FG,
theme.PRIMARY_FG,
format
)
end
@ -623,21 +623,21 @@ local default_table_font_spec = make_font_spec(FONT, TABLE_FONT_SIZE, false)
local default_table_style = Table.style(
Rect.config(
s.closed_poly(TABLE_LINE_THICKNESS, CAIRO_LINE_JOIN_MITER),
Theme.BORDER_FG
theme.BORDER_FG
),
Line.config(
s.line(TABLE_LINE_THICKNESS, CAIRO_LINE_CAP_BUTT),
Theme.BORDER_FG,
theme.BORDER_FG,
true
),
Table.header_config(
default_table_font_spec,
Theme.PRIMARY_FG,
theme.PRIMARY_FG,
TABLE_HEADER_PAD
),
Table.body_config(
default_table_font_spec,
Theme.INACTIVE_TEXT_FG,
theme.INACTIVE_TEXT_FG,
TABLE_BODY_FORMAT
),
F.padding(
@ -665,9 +665,9 @@ M.initPanel = function(x, y, w, h, thickness)
F.make_box(x, y, w, h),
Rect.config(
s.closed_poly(thickness, CAIRO_LINE_JOIN_MITER),
Theme.BORDER_FG
theme.BORDER_FG
),
Theme.PANEL_BG
theme.PANEL_BG
)
end

View File

@ -1,7 +1,7 @@
local Line = require 'Line'
local Util = require 'Util'
local Common = require 'Common'
local Geometry = require 'Geometry'
local common = require 'common'
local geometry = require 'geometry'
return function()
local FS_PATHS = {'/', '/boot', '/home', '/mnt/data', '/mnt/dcache', "/tmp"}
@ -13,29 +13,29 @@ return function()
-----------------------------------------------------------------------------
-- header
local header = Common.Header(
Geometry.RIGHT_X,
local header = common.Header(
geometry.RIGHT_X,
MODULE_Y,
Geometry.SECTION_WIDTH,
geometry.SECTION_WIDTH,
'FILE SYSTEMS'
)
-----------------------------------------------------------------------------
-- smartd
local smart = Common.initTextRow(
Geometry.RIGHT_X,
local smart = common.initTextRow(
geometry.RIGHT_X,
header.bottom_y,
Geometry.SECTION_WIDTH,
geometry.SECTION_WIDTH,
'SMART Daemon'
)
local SEP_Y = header.bottom_y + SEPARATOR_SPACING
local separator = Common.initSeparator(
Geometry.RIGHT_X,
local separator = common.initSeparator(
geometry.RIGHT_X,
SEP_Y,
Geometry.SECTION_WIDTH
geometry.SECTION_WIDTH
)
-----------------------------------------------------------------------------
@ -43,10 +43,10 @@ return function()
local BAR_Y = SEP_Y + SEPARATOR_SPACING
local fs = Common.compound_bar(
Geometry.RIGHT_X,
local fs = common.compound_bar(
geometry.RIGHT_X,
BAR_Y,
Geometry.SECTION_WIDTH,
geometry.SECTION_WIDTH,
BAR_PAD,
{'root', 'boot', 'home', 'data', 'dcache', 'tmpfs'},
SPACING,
@ -66,25 +66,25 @@ return function()
local update = function(trigger)
if trigger == 0 then
local smart_pid = Util.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
local percent = Util.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
local draw_static = function(cr)
Common.drawHeader(cr, header)
Common.text_row_draw_static(smart, cr)
common.drawHeader(cr, header)
common.text_row_draw_static(smart, cr)
Line.draw(separator, cr)
Common.compound_bar_draw_static(fs, cr)
common.compound_bar_draw_static(fs, cr)
end
local draw_dynamic = function(cr)
Common.text_row_draw_dynamic(smart, cr)
Common.compound_bar_draw_dynamic(fs, cr)
common.text_row_draw_dynamic(smart, cr)
common.compound_bar_draw_dynamic(fs, cr)
end
return {static = draw_static, dynamic = draw_dynamic, update = update}

View File

@ -1,8 +1,8 @@
local Text = require 'Text'
local Line = require 'Line'
local Util = require 'Util'
local Common = require 'Common'
local Geometry = require 'Geometry'
local common = require 'common'
local geometry = require 'geometry'
return function(update_freq)
local MODULE_Y = 145
@ -18,29 +18,29 @@ return function(update_freq)
-----------------------------------------------------------------------------
-- header
local header = Common.Header(
Geometry.LEFT_X,
local header = common.Header(
geometry.LEFT_X,
MODULE_Y,
Geometry.SECTION_WIDTH,
geometry.SECTION_WIDTH,
'NVIDIA GRAPHICS'
)
-----------------------------------------------------------------------------
-- gpu status
local status = Common.initTextRow(
Geometry.LEFT_X,
local status = common.initTextRow(
geometry.LEFT_X,
header.bottom_y,
Geometry.SECTION_WIDTH,
geometry.SECTION_WIDTH,
'Status'
)
local SEP_Y1 = header.bottom_y + SEPARATOR_SPACING
local separator1 = Common.initSeparator(
Geometry.LEFT_X,
local separator1 = common.initSeparator(
geometry.LEFT_X,
SEP_Y1,
Geometry.SECTION_WIDTH
geometry.SECTION_WIDTH
)
-----------------------------------------------------------------------------
@ -48,10 +48,10 @@ return function(update_freq)
local INTERNAL_TEMP_Y = SEP_Y1 + SEPARATOR_SPACING
local internal_temp = Common.initTextRowCrit(
Geometry.LEFT_X,
local internal_temp = common.initTextRowCrit(
geometry.LEFT_X,
INTERNAL_TEMP_Y,
Geometry.SECTION_WIDTH,
geometry.SECTION_WIDTH,
'Internal Temperature',
function(s)
if s == -1 then return NA else return string.format('%s°C', s) end
@ -61,10 +61,10 @@ return function(update_freq)
local SEP_Y2 = INTERNAL_TEMP_Y + SEPARATOR_SPACING
local separator2 = Common.initSeparator(
Geometry.LEFT_X,
local separator2 = common.initSeparator(
geometry.LEFT_X,
SEP_Y2,
Geometry.SECTION_WIDTH
geometry.SECTION_WIDTH
)
-----------------------------------------------------------------------------
@ -72,20 +72,20 @@ return function(update_freq)
local CLOCK_SPEED_Y = SEP_Y2 + SEPARATOR_SPACING
local clock_speed = Common.initTextRows(
Geometry.LEFT_X,
local clock_speed = common.initTextRows(
geometry.LEFT_X,
CLOCK_SPEED_Y,
Geometry.SECTION_WIDTH,
geometry.SECTION_WIDTH,
TEXT_SPACING,
{'GPU Clock Speed', 'Memory Clock Speed'}
{'GPU Clock Speed', 'memory Clock Speed'}
)
local SEP_Y3 = CLOCK_SPEED_Y + TEXT_SPACING * 2
local separator3 = Common.initSeparator(
Geometry.LEFT_X,
local separator3 = common.initSeparator(
geometry.LEFT_X,
SEP_Y3,
Geometry.SECTION_WIDTH
geometry.SECTION_WIDTH
)
-----------------------------------------------------------------------------
@ -96,10 +96,10 @@ return function(update_freq)
end
local build_plot = function(y, label)
return Common.initPercentPlot_formatted(
Geometry.LEFT_X,
return common.initPercentPlot_formatted(
geometry.LEFT_X,
y,
Geometry.SECTION_WIDTH,
geometry.SECTION_WIDTH,
PLOT_HEIGHT,
PLOT_SEC_BREAK,
label,
@ -115,7 +115,7 @@ return function(update_freq)
-- 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
@ -135,8 +135,8 @@ return function(update_freq)
-- <gpu_freq>,<mem_freq>
-- graphics=<gpu_util>, memory=<mem_util>, video=<vid_util>, PCIe=<pci_util>
local NV_QUERY = 'nvidia-settings -t'..
' -q UsedDedicatedGPUMemory'..
' -q TotalDedicatedGPUMemory'..
' -q UsedDedicatedGPUmemory'..
' -q TotalDedicatedGPUmemory'..
' -q ThermalSensorReading'..
' -q [gpu:0]/GPUCurrentClockFreqs'..
' -q [gpu:0]/GPUUtilization'
@ -150,12 +150,12 @@ return function(update_freq)
local GPU_BUS_CTRL = '/sys/bus/pci/devices/0000:01:00.0/power/control'
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)
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()
@ -165,19 +165,19 @@ return function(update_freq)
Text.set(status.value, 'Error')
nvidia_off()
else
Common.text_row_set(status, '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, temp_reading)
Common.text_rows_set(clock_speed, 1, gpu_frequency..' Mhz')
Common.text_rows_set(clock_speed, 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, gpu_utilization)
Common.percent_plot_set(mem_util, used_memory / total_memory * 100)
Common.percent_plot_set(vid_util, 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, 'Off')
@ -189,29 +189,29 @@ return function(update_freq)
-- main drawing functions
local draw_static = function(cr)
Common.drawHeader(cr, header)
common.drawHeader(cr, header)
Common.text_row_draw_static(status, cr)
common.text_row_draw_static(status, cr)
Line.draw(separator1, cr)
Common.text_row_crit_draw_static(internal_temp, cr)
common.text_row_crit_draw_static(internal_temp, cr)
Line.draw(separator2, cr)
Common.text_rows_draw_static(clock_speed, cr)
common.text_rows_draw_static(clock_speed, cr)
Line.draw(separator3, cr)
Common.percent_plot_draw_static(gpu_util, cr)
Common.percent_plot_draw_static(mem_util, cr)
Common.percent_plot_draw_static(vid_util, cr)
common.percent_plot_draw_static(gpu_util, cr)
common.percent_plot_draw_static(mem_util, cr)
common.percent_plot_draw_static(vid_util, cr)
end
local draw_dynamic = function(cr)
Common.text_row_draw_dynamic(status, cr)
Common.text_row_crit_draw_dynamic(internal_temp, cr)
Common.text_rows_draw_dynamic(clock_speed, cr)
Common.percent_plot_draw_dynamic(gpu_util, cr)
Common.percent_plot_draw_dynamic(mem_util, cr)
Common.percent_plot_draw_dynamic(vid_util, cr)
common.text_row_draw_dynamic(status, cr)
common.text_row_crit_draw_dynamic(internal_temp, cr)
common.text_rows_draw_dynamic(clock_speed, cr)
common.percent_plot_draw_dynamic(gpu_util, cr)
common.percent_plot_draw_dynamic(mem_util, cr)
common.percent_plot_draw_dynamic(vid_util, cr)
end
return {static = draw_static, dynamic = draw_dynamic, update = update}

View File

@ -1,8 +1,8 @@
local Timeseries = require 'Timeseries'
local Table = require 'Table'
local Util = require 'Util'
local Common = require 'Common'
local Geometry = require 'Geometry'
local common = require 'common'
local geometry = require 'geometry'
local func = require 'func'
return function(update_freq)
@ -30,10 +30,10 @@ return function(update_freq)
-----------------------------------------------------------------------------
-- header
local header = Common.Header(
Geometry.RIGHT_X,
local header = common.Header(
geometry.RIGHT_X,
MODULE_Y,
Geometry.SECTION_WIDTH,
geometry.SECTION_WIDTH,
'MEMORY'
)
@ -51,11 +51,11 @@ return function(update_freq)
return string.format('%.0f%%', x * 100)
end
local MEM_X = Geometry.RIGHT_X + DIAL_RADIUS + DIAL_THICKNESS / 2
local MEM_X = geometry.RIGHT_X + DIAL_RADIUS + DIAL_THICKNESS / 2
local MEM_Y = header.bottom_y + DIAL_RADIUS + DIAL_THICKNESS / 2
local DIAL_DIAMETER = DIAL_RADIUS * 2 + DIAL_THICKNESS
local mem = Common.dial(
local mem = common.dial(
MEM_X,
MEM_Y,
DIAL_RADIUS,
@ -69,7 +69,7 @@ return function(update_freq)
local SWAP_X = MEM_X + DIAL_DIAMETER + DIAL_SPACING
local swap = Common.dial(
local swap = common.dial(
SWAP_X,
MEM_Y,
DIAL_RADIUS,
@ -83,9 +83,9 @@ return function(update_freq)
local CACHE_Y = header.bottom_y + CACHE_Y_OFFSET
local CACHE_X = SWAP_X + CACHE_X_OFFSET + DIAL_DIAMETER / 2
local CACHE_WIDTH = Geometry.RIGHT_X + Geometry.SECTION_WIDTH - CACHE_X
local CACHE_WIDTH = geometry.RIGHT_X + geometry.SECTION_WIDTH - CACHE_X
local cache = Common.initTextRows_formatted(
local cache = common.initTextRows_formatted(
CACHE_X,
CACHE_Y,
CACHE_WIDTH,
@ -99,12 +99,12 @@ return function(update_freq)
local PLOT_Y = header.bottom_y + PLOT_SECTION_BREAK + DIAL_DIAMETER
local plot = Common.initThemedLabelPlot(
Geometry.RIGHT_X,
local plot = common.initthemedLabelPlot(
geometry.RIGHT_X,
PLOT_Y,
Geometry.SECTION_WIDTH,
geometry.SECTION_WIDTH,
PLOT_HEIGHT,
Common.percent_label_config,
common.percent_label_config,
update_freq
)
@ -122,10 +122,10 @@ return function(update_freq)
end,
func.seq(NUM_ROWS))
local tbl = Common.initTable(
Geometry.RIGHT_X,
local tbl = common.initTable(
geometry.RIGHT_X,
PLOT_Y + PLOT_HEIGHT + TABLE_SECTION_BREAK,
Geometry.SECTION_WIDTH,
geometry.SECTION_WIDTH,
TABLE_HEIGHT,
NUM_ROWS,
{'Name', 'PID', 'Mem (%)'}
@ -153,13 +153,13 @@ return function(update_freq)
buffers -
sreclaimable) / memtotal
Common.dial_set(mem, used_percent)
Common.dial_set(swap, (swaptotal - swapfree) / swaptotal)
common.dial_set(mem, used_percent)
common.dial_set(swap, (swaptotal - swapfree) / swaptotal)
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)
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)
@ -171,18 +171,18 @@ return function(update_freq)
end
local draw_static = function(cr)
Common.drawHeader(cr, header)
Common.dial_draw_static(mem, cr)
Common.dial_draw_static(swap, cr)
Common.text_rows_draw_static(cache, cr)
common.drawHeader(cr, header)
common.dial_draw_static(mem, cr)
common.dial_draw_static(swap, cr)
common.text_rows_draw_static(cache, cr)
Timeseries.draw_static(plot, cr)
Table.draw_static(tbl, cr)
end
local draw_dynamic = function(cr)
Common.dial_draw_dynamic(mem, cr)
Common.dial_draw_dynamic(swap, cr)
Common.text_rows_draw_dynamic(cache, cr)
common.dial_draw_dynamic(mem, cr)
common.dial_draw_dynamic(swap, cr)
common.text_rows_draw_dynamic(cache, cr)
Timeseries.draw_dynamic(plot, cr)
Table.draw_dynamic(tbl, cr)
end

View File

@ -1,6 +1,6 @@
local Util = require 'Util'
local Common = require 'Common'
local Geometry = require 'Geometry'
local common = require 'common'
local geometry = require 'geometry'
local func = require 'func'
return function(update_freq)
@ -49,13 +49,13 @@ return function(update_freq)
end
local build_plot = function(y, label, init)
return Common.build_rate_timeseries(
Geometry.CENTER_RIGHT_X,
return common.build_rate_timeseries(
geometry.CENTER_RIGHT_X,
y,
Geometry.SECTION_WIDTH,
geometry.SECTION_WIDTH,
PLOT_HEIGHT,
value_format_function,
Common.converted_y_label_format_generator('b'),
common.converted_y_label_format_generator('b'),
PLOT_SEC_BREAK,
label,
2,
@ -67,10 +67,10 @@ return function(update_freq)
-----------------------------------------------------------------------------
-- header
local header = Common.Header(
Geometry.CENTER_RIGHT_X,
Geometry.TOP_Y,
Geometry.SECTION_WIDTH,
local header = common.Header(
geometry.CENTER_RIGHT_X,
geometry.TOP_Y,
geometry.SECTION_WIDTH,
'NETWORK'
)
@ -90,19 +90,19 @@ return function(update_freq)
local update = function()
local rx_bits, tx_bits = read_interfaces()
Common.update_rate_timeseries(rx, rx_bits)
Common.update_rate_timeseries(tx, tx_bits)
common.update_rate_timeseries(rx, rx_bits)
common.update_rate_timeseries(tx, tx_bits)
end
local draw_static = function(cr)
Common.drawHeader(cr, header)
Common.annotated_scale_plot_draw_static(rx, cr)
Common.annotated_scale_plot_draw_static(tx, cr)
common.drawHeader(cr, header)
common.annotated_scale_plot_draw_static(rx, cr)
common.annotated_scale_plot_draw_static(tx, cr)
end
local draw_dynamic = function(cr)
Common.annotated_scale_plot_draw_dynamic(rx, cr)
Common.annotated_scale_plot_draw_dynamic(tx, cr)
common.annotated_scale_plot_draw_dynamic(rx, cr)
common.annotated_scale_plot_draw_dynamic(tx, cr)
end
return {static = draw_static, dynamic = draw_dynamic, update = update}

View File

@ -1,5 +1,5 @@
local Common = require 'Common'
local Geometry = require 'Geometry'
local common = require 'common'
local geometry = require 'geometry'
return function()
local TEXT_SPACING = 20
@ -7,17 +7,17 @@ return function()
local __string_match = string.match
local __string_gmatch = string.gmatch
local header = Common.Header(
Geometry.RIGHT_X,
Geometry.TOP_Y,
Geometry.SECTION_WIDTH,
local header = common.Header(
geometry.RIGHT_X,
geometry.TOP_Y,
geometry.SECTION_WIDTH,
'PACMAN'
)
local rows = Common.initTextRows(
Geometry.RIGHT_X,
local rows = common.initTextRows(
geometry.RIGHT_X,
header.bottom_y,
Geometry.SECTION_WIDTH,
geometry.SECTION_WIDTH,
TEXT_SPACING,
{'Total', 'Explicit', 'Outdated', 'Orphaned', 'Local'}
)
@ -27,23 +27,23 @@ return function()
if stats then
local i = 1
for v in __string_gmatch(stats, '%d+') do
Common.text_rows_set(rows, i, v)
common.text_rows_set(rows, i, v)
i = i + 1
end
else
for i=1, 5 do
Common.text_rows_set(rows, i, 'N/A')
common.text_rows_set(rows, i, 'N/A')
end
end
end
local draw_static = function(cr)
Common.drawHeader(cr, header)
Common.text_rows_draw_static(rows, cr)
common.drawHeader(cr, header)
common.text_rows_draw_static(rows, cr)
end
local draw_dynamic = function(cr)
Common.text_rows_draw_dynamic(rows, cr)
common.text_rows_draw_dynamic(rows, cr)
end
return {static = draw_static, dynamic = draw_dynamic, update = update}

View File

@ -1,6 +1,6 @@
local Util = require 'Util'
local Common = require 'Common'
local Geometry = require 'Geometry'
local common = require 'common'
local geometry = require 'geometry'
return function(update_freq)
local MODULE_Y = 380
@ -41,7 +41,7 @@ return function(update_freq)
end
local power_label_function = function(plot_max)
local fmt = Common.y_label_format_string(plot_max, 'W')
local fmt = common.y_label_format_string(plot_max, 'W')
return function(watts) return string.format(fmt, watts) end
end
@ -50,10 +50,10 @@ return function(update_freq)
end
local build_rate_plot = function(y, label, init)
return Common.build_rate_timeseries(
Geometry.RIGHT_X,
return common.build_rate_timeseries(
geometry.RIGHT_X,
y,
Geometry.SECTION_WIDTH,
geometry.SECTION_WIDTH,
PLOT_HEIGHT,
format_rapl,
power_label_function,
@ -68,10 +68,10 @@ return function(update_freq)
-----------------------------------------------------------------------------
-- header
local header = Common.Header(
Geometry.RIGHT_X,
local header = common.Header(
geometry.RIGHT_X,
MODULE_Y,
Geometry.SECTION_WIDTH,
geometry.SECTION_WIDTH,
'POWER'
)
@ -98,10 +98,10 @@ return function(update_freq)
end
local BAT_Y = DRAM_Y + PLOT_SEC_BREAK * 2 + PLOT_HEIGHT
local bat = Common.initLabeledScalePlot(
Geometry.RIGHT_X,
local bat = common.initLabeledScalePlot(
geometry.RIGHT_X,
BAT_Y,
Geometry.SECTION_WIDTH,
geometry.SECTION_WIDTH,
PLOT_HEIGHT,
format_ac,
power_label_function,
@ -115,22 +115,22 @@ return function(update_freq)
-- main functions
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))
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)
Common.drawHeader(cr, header)
Common.annotated_scale_plot_draw_static(pkg0, cr)
Common.annotated_scale_plot_draw_static(dram, cr)
Common.annotated_scale_plot_draw_static(bat, cr)
common.drawHeader(cr, header)
common.annotated_scale_plot_draw_static(pkg0, cr)
common.annotated_scale_plot_draw_static(dram, cr)
common.annotated_scale_plot_draw_static(bat, cr)
end
local draw_dynamic = function(cr)
Common.annotated_scale_plot_draw_dynamic(pkg0, cr)
Common.annotated_scale_plot_draw_dynamic(dram, cr)
Common.annotated_scale_plot_draw_dynamic(bat, cr)
common.annotated_scale_plot_draw_dynamic(pkg0, cr)
common.annotated_scale_plot_draw_dynamic(dram, cr)
common.annotated_scale_plot_draw_dynamic(bat, cr)
end
return {static = draw_static, dynamic = draw_dynamic, update = update}

View File

@ -2,8 +2,8 @@ local CompoundDial = require 'CompoundDial'
local Line = require 'Line'
local Table = require 'Table'
local Util = require 'Util'
local Common = require 'Common'
local Geometry = require 'Geometry'
local common = require 'common'
local geometry = require 'geometry'
local CPU = require 'CPU'
local func = require 'func'
@ -24,10 +24,10 @@ return function(update_freq)
-----------------------------------------------------------------------------
-- header
local header = Common.Header(
Geometry.LEFT_X,
local header = common.Header(
geometry.LEFT_X,
MODULE_Y,
Geometry.SECTION_WIDTH,
geometry.SECTION_WIDTH,
'PROCESSOR'
)
@ -46,7 +46,7 @@ return function(update_freq)
local create_core = function(x, y)
return {
loads = Common.compound_dial(
loads = common.compound_dial(
x,
y,
DIAL_OUTER_RADIUS,
@ -55,7 +55,7 @@ return function(update_freq)
0.8,
nthreads
),
coretemp = Common.initTextRing(
coretemp = common.initTextRing(
x,
y,
DIAL_INNER_RADIUS - 2,
@ -66,8 +66,8 @@ return function(update_freq)
end
for c = 1, ncores do
local dial_x = Geometry.LEFT_X + DIAL_OUTER_RADIUS +
(Geometry.SECTION_WIDTH - 2 * DIAL_OUTER_RADIUS) * (c - 1) / 3
local dial_x = geometry.LEFT_X + DIAL_OUTER_RADIUS +
(geometry.SECTION_WIDTH - 2 * DIAL_OUTER_RADIUS) * (c - 1) / 3
local dial_y = header.bottom_y + DIAL_OUTER_RADIUS
cores[c] = create_core(dial_x, dial_y)
end
@ -77,10 +77,10 @@ return function(update_freq)
local HWP_Y = header.bottom_y + DIAL_OUTER_RADIUS * 2 + PLOT_SECTION_BREAK
local cpu_status = Common.initTextRows(
Geometry.LEFT_X,
local cpu_status = common.initTextRows(
geometry.LEFT_X,
HWP_Y,
Geometry.SECTION_WIDTH,
geometry.SECTION_WIDTH,
TEXT_SPACING,
{'HWP Preference', 'Ave Freq'}
)
@ -90,10 +90,10 @@ return function(update_freq)
local SEP_Y = HWP_Y + TEXT_SPACING + SEPARATOR_SPACING
local separator = Common.initSeparator(
Geometry.LEFT_X,
local separator = common.initSeparator(
geometry.LEFT_X,
SEP_Y,
Geometry.SECTION_WIDTH
geometry.SECTION_WIDTH
)
-----------------------------------------------------------------------------
@ -101,10 +101,10 @@ return function(update_freq)
local LOAD_Y = SEP_Y + SEPARATOR_SPACING
local total_load = Common.initPercentPlot(
Geometry.LEFT_X,
local total_load = common.initPercentPlot(
geometry.LEFT_X,
LOAD_Y,
Geometry.SECTION_WIDTH,
geometry.SECTION_WIDTH,
PLOT_HEIGHT,
PLOT_SECTION_BREAK,
"Total Load",
@ -122,10 +122,10 @@ return function(update_freq)
func.seq(NUM_ROWS)
)
local tbl = Common.initTable(
Geometry.LEFT_X,
local tbl = common.initTable(
geometry.LEFT_X,
PLOT_Y + PLOT_HEIGHT + TABLE_SECTION_BREAK,
Geometry.SECTION_WIDTH,
geometry.SECTION_WIDTH,
TABLE_HEIGHT,
NUM_ROWS,
{'Name', 'PID', 'CPU (%)'}
@ -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, 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, 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)
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
@ -171,17 +171,17 @@ return function(update_freq)
end
local draw_static = function(cr)
Common.drawHeader(cr, header)
common.drawHeader(cr, header)
for i = 1, #cores do
Common.text_ring_draw_static(cores[i].coretemp, cr)
common.text_ring_draw_static(cores[i].coretemp, cr)
CompoundDial.draw_static(cores[i].loads, cr)
end
Common.text_rows_draw_static(cpu_status, cr)
common.text_rows_draw_static(cpu_status, cr)
Line.draw(separator, cr)
Common.percent_plot_draw_static(total_load, cr)
common.percent_plot_draw_static(total_load, cr)
Table.draw_static(tbl, cr)
end
@ -189,11 +189,11 @@ return function(update_freq)
local draw_dynamic = function(cr)
for i = 1, #cores do
CompoundDial.draw_dynamic(cores[i].loads, cr)
Common.text_ring_draw_dynamic(cores[i].coretemp, cr)
common.text_ring_draw_dynamic(cores[i].coretemp, cr)
end
Common.text_rows_draw_dynamic(cpu_status, cr)
Common.percent_plot_draw_dynamic(total_load, cr)
common.text_rows_draw_dynamic(cpu_status, cr)
common.percent_plot_draw_dynamic(total_load, cr)
Table.draw_dynamic(tbl, cr)
end

View File

@ -1,6 +1,6 @@
local Util = require 'Util'
local Common = require 'Common'
local Geometry = require 'Geometry'
local common = require 'common'
local geometry = require 'geometry'
local func = require 'func'
return function(update_freq)
@ -43,13 +43,13 @@ return function(update_freq)
end
local build_plot = function(y, label, init)
return Common.build_rate_timeseries(
Geometry.CENTER_LEFT_X,
return common.build_rate_timeseries(
geometry.CENTER_LEFT_X,
y,
Geometry.SECTION_WIDTH,
geometry.SECTION_WIDTH,
PLOT_HEIGHT,
format_value_function,
Common.converted_y_label_format_generator('B'),
common.converted_y_label_format_generator('B'),
PLOT_SEC_BREAK,
label,
2,
@ -61,10 +61,10 @@ return function(update_freq)
-----------------------------------------------------------------------------
-- header
local header = Common.Header(
Geometry.CENTER_LEFT_X,
Geometry.TOP_Y,
Geometry.SECTION_WIDTH,
local header = common.Header(
geometry.CENTER_LEFT_X,
geometry.TOP_Y,
geometry.SECTION_WIDTH,
'INPUT / OUTPUT'
)
@ -87,19 +87,19 @@ return function(update_freq)
local update = function()
local read_bytes, write_bytes = read_devices()
Common.update_rate_timeseries(reads, read_bytes)
Common.update_rate_timeseries(writes, write_bytes)
common.update_rate_timeseries(reads, read_bytes)
common.update_rate_timeseries(writes, write_bytes)
end
local draw_static = function(cr)
Common.drawHeader(cr, header)
Common.annotated_scale_plot_draw_static(reads, cr)
Common.annotated_scale_plot_draw_static(writes, cr)
common.drawHeader(cr, header)
common.annotated_scale_plot_draw_static(reads, cr)
common.annotated_scale_plot_draw_static(writes, cr)
end
local draw_dynamic = function(cr)
Common.annotated_scale_plot_draw_dynamic(reads, cr)
Common.annotated_scale_plot_draw_dynamic(writes, cr)
common.annotated_scale_plot_draw_dynamic(reads, cr)
common.annotated_scale_plot_draw_dynamic(writes, cr)
end
return {static = draw_static, dynamic = draw_dynamic, update = update}

View File

@ -1,5 +1,5 @@
local Common = require 'Common'
local Geometry = require 'Geometry'
local common = require 'common'
local geometry = require 'geometry'
local FillRect = require 'FillRect'
return function(left_modules, center_modules, right_modules)
@ -15,7 +15,7 @@ return function(left_modules, center_modules, right_modules)
-- move over by half a pixel so the lines don't need to be antialiased
local _x = x + 0.5
local _y = y + 0.5
local panel = Common.initPanel(_x, _y, w, h, panel_line_thickness)
local panel = common.initPanel(_x, _y, w, h, panel_line_thickness)
local cs_x = _x - panel_line_thickness * 0.5
local cs_y = _y - panel_line_thickness * 0.5
local cs_w = w + panel_line_thickness
@ -35,26 +35,26 @@ return function(left_modules, center_modules, right_modules)
end
local cs_left = _make_static_surface(
Geometry.LEFT_X - Geometry.PANEL_MARGIN_X,
Geometry.TOP_Y - Geometry.PANEL_MARGIN_Y,
Geometry.SECTION_WIDTH + Geometry.PANEL_MARGIN_X * 2,
Geometry.SIDE_HEIGHT + Geometry.PANEL_MARGIN_Y * 2,
geometry.LEFT_X - geometry.PANEL_MARGIN_X,
geometry.TOP_Y - geometry.PANEL_MARGIN_Y,
geometry.SECTION_WIDTH + geometry.PANEL_MARGIN_X * 2,
geometry.SIDE_HEIGHT + geometry.PANEL_MARGIN_Y * 2,
left_modules
)
local cs_center = _make_static_surface(
Geometry.CENTER_LEFT_X - Geometry.PANEL_MARGIN_X,
Geometry.TOP_Y - Geometry.PANEL_MARGIN_Y,
Geometry.CENTER_WIDTH + Geometry.PANEL_MARGIN_Y * 2 + Geometry.CENTER_PAD,
Geometry.CENTER_HEIGHT + Geometry.PANEL_MARGIN_Y * 2,
geometry.CENTER_LEFT_X - geometry.PANEL_MARGIN_X,
geometry.TOP_Y - geometry.PANEL_MARGIN_Y,
geometry.CENTER_WIDTH + geometry.PANEL_MARGIN_Y * 2 + geometry.CENTER_PAD,
geometry.CENTER_HEIGHT + geometry.PANEL_MARGIN_Y * 2,
center_modules
)
local cs_right = _make_static_surface(
Geometry.RIGHT_X - Geometry.PANEL_MARGIN_X,
Geometry.TOP_Y - Geometry.PANEL_MARGIN_Y,
Geometry.SECTION_WIDTH + Geometry.PANEL_MARGIN_X * 2,
Geometry.SIDE_HEIGHT + Geometry.PANEL_MARGIN_Y * 2,
geometry.RIGHT_X - geometry.PANEL_MARGIN_X,
geometry.TOP_Y - geometry.PANEL_MARGIN_Y,
geometry.SECTION_WIDTH + geometry.PANEL_MARGIN_X * 2,
geometry.SIDE_HEIGHT + geometry.PANEL_MARGIN_Y * 2,
right_modules
)

View File

@ -1,23 +1,23 @@
local Util = require 'Util'
local Common = require 'Common'
local Geometry = require 'Geometry'
local common = require 'common'
local geometry = require 'geometry'
return function()
local TEXT_SPACING = 20
local __string_match = string.match
local header = Common.Header(
Geometry.LEFT_X,
Geometry.TOP_Y,
Geometry.SECTION_WIDTH,
local header = common.Header(
geometry.LEFT_X,
geometry.TOP_Y,
geometry.SECTION_WIDTH,
'SYSTEM'
)
local rows = Common.initTextRows(
Geometry.LEFT_X,
local rows = common.initTextRows(
geometry.LEFT_X,
header.bottom_y,
Geometry.SECTION_WIDTH,
geometry.SECTION_WIDTH,
TEXT_SPACING,
{'Kernel', 'Uptime', 'Last Upgrade', 'Last Sync'}
)
@ -28,19 +28,19 @@ 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, 3, last_update)
Common.text_rows_set(rows, 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)
end
local draw_static = function(cr)
Common.drawHeader(cr, header)
Common.text_rows_draw_static(rows, cr)
common.drawHeader(cr, header)
common.text_rows_draw_static(rows, cr)
end
local draw_dynamic = function(cr)
Common.text_rows_draw_dynamic(rows, cr)
common.text_rows_draw_dynamic(rows, cr)
end
return {static = draw_static, dynamic = draw_dynamic, update = update}

View File

@ -17,16 +17,16 @@ package.path = ABS_PATH..'?.lua;'..
ABS_PATH..'core/widget/poly/?.lua;'
local Util = require 'Util'
local System = require 'System'
local Network = require 'Network'
local Processor = require 'Processor'
local FileSystem = require 'FileSystem'
local Pacman = require 'Pacman'
local Power = require 'Power'
local ReadWrite = require 'ReadWrite'
local Graphics = require 'Graphics'
local Memory = require 'Memory'
local Static = require 'Static'
local system = require 'system'
local network = require 'network'
local processor = require 'processor'
local filesystem = require 'filesystem'
local pacman = require 'pacman'
local power = require 'power'
local readwrite = require 'readwrite'
local graphics = require 'graphics'
local memory = require 'memory'
local static = require 'static'
local using_ac = function()
-- for some reason it is much more efficient to test if the battery
@ -41,17 +41,17 @@ function conky_start(update_interval)
local update_freq = 1 / update_interval
local mem = Memory(update_freq)
local rw = ReadWrite(update_freq)
local net = Network(update_freq)
local pwr = Power(update_freq)
local fs = FileSystem()
local sys = System()
local gfx = Graphics(update_freq)
local proc = Processor(update_freq)
local pcm = Pacman()
local mem = memory(update_freq)
local rw = readwrite(update_freq)
local net = network(update_freq)
local pwr = power(update_freq)
local fs = filesystem()
local sys = system()
local gfx = graphics(update_freq)
local proc = processor(update_freq)
local pcm = pacman()
local draw_static = Static(
local draw_static = static(
{sys.static, gfx.static, proc.static},
{rw.static, net.static},
{pcm.static, fs.static, pwr.static, mem.static}