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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -2,8 +2,8 @@ local CompoundDial = require 'CompoundDial'
local Line = require 'Line' local Line = require 'Line'
local Table = require 'Table' local Table = require 'Table'
local Util = require 'Util' local Util = require 'Util'
local Common = require 'Common' local common = require 'common'
local Geometry = require 'Geometry' local geometry = require 'geometry'
local CPU = require 'CPU' local CPU = require 'CPU'
local func = require 'func' local func = require 'func'
@ -24,10 +24,10 @@ return function(update_freq)
----------------------------------------------------------------------------- -----------------------------------------------------------------------------
-- header -- header
local header = Common.Header( local header = common.Header(
Geometry.LEFT_X, geometry.LEFT_X,
MODULE_Y, MODULE_Y,
Geometry.SECTION_WIDTH, geometry.SECTION_WIDTH,
'PROCESSOR' 'PROCESSOR'
) )
@ -46,7 +46,7 @@ return function(update_freq)
local create_core = function(x, y) local create_core = function(x, y)
return { return {
loads = Common.compound_dial( loads = common.compound_dial(
x, x,
y, y,
DIAL_OUTER_RADIUS, DIAL_OUTER_RADIUS,
@ -55,7 +55,7 @@ return function(update_freq)
0.8, 0.8,
nthreads nthreads
), ),
coretemp = Common.initTextRing( coretemp = common.initTextRing(
x, x,
y, y,
DIAL_INNER_RADIUS - 2, DIAL_INNER_RADIUS - 2,
@ -66,8 +66,8 @@ return function(update_freq)
end end
for c = 1, ncores do for c = 1, ncores do
local dial_x = Geometry.LEFT_X + DIAL_OUTER_RADIUS + local dial_x = geometry.LEFT_X + DIAL_OUTER_RADIUS +
(Geometry.SECTION_WIDTH - 2 * DIAL_OUTER_RADIUS) * (c - 1) / 3 (geometry.SECTION_WIDTH - 2 * DIAL_OUTER_RADIUS) * (c - 1) / 3
local dial_y = header.bottom_y + DIAL_OUTER_RADIUS local dial_y = header.bottom_y + DIAL_OUTER_RADIUS
cores[c] = create_core(dial_x, dial_y) cores[c] = create_core(dial_x, dial_y)
end end
@ -77,10 +77,10 @@ return function(update_freq)
local HWP_Y = header.bottom_y + DIAL_OUTER_RADIUS * 2 + PLOT_SECTION_BREAK local HWP_Y = header.bottom_y + DIAL_OUTER_RADIUS * 2 + PLOT_SECTION_BREAK
local cpu_status = Common.initTextRows( local cpu_status = common.initTextRows(
Geometry.LEFT_X, geometry.LEFT_X,
HWP_Y, HWP_Y,
Geometry.SECTION_WIDTH, geometry.SECTION_WIDTH,
TEXT_SPACING, TEXT_SPACING,
{'HWP Preference', 'Ave Freq'} {'HWP Preference', 'Ave Freq'}
) )
@ -90,10 +90,10 @@ return function(update_freq)
local SEP_Y = HWP_Y + TEXT_SPACING + SEPARATOR_SPACING local SEP_Y = HWP_Y + TEXT_SPACING + SEPARATOR_SPACING
local separator = Common.initSeparator( local separator = common.initSeparator(
Geometry.LEFT_X, geometry.LEFT_X,
SEP_Y, SEP_Y,
Geometry.SECTION_WIDTH geometry.SECTION_WIDTH
) )
----------------------------------------------------------------------------- -----------------------------------------------------------------------------
@ -101,10 +101,10 @@ return function(update_freq)
local LOAD_Y = SEP_Y + SEPARATOR_SPACING local LOAD_Y = SEP_Y + SEPARATOR_SPACING
local total_load = Common.initPercentPlot( local total_load = common.initPercentPlot(
Geometry.LEFT_X, geometry.LEFT_X,
LOAD_Y, LOAD_Y,
Geometry.SECTION_WIDTH, geometry.SECTION_WIDTH,
PLOT_HEIGHT, PLOT_HEIGHT,
PLOT_SECTION_BREAK, PLOT_SECTION_BREAK,
"Total Load", "Total Load",
@ -122,10 +122,10 @@ return function(update_freq)
func.seq(NUM_ROWS) func.seq(NUM_ROWS)
) )
local tbl = Common.initTable( local tbl = common.initTable(
Geometry.LEFT_X, geometry.LEFT_X,
PLOT_Y + PLOT_HEIGHT + TABLE_SECTION_BREAK, PLOT_Y + PLOT_HEIGHT + TABLE_SECTION_BREAK,
Geometry.SECTION_WIDTH, geometry.SECTION_WIDTH,
TABLE_HEIGHT, TABLE_HEIGHT,
NUM_ROWS, NUM_ROWS,
{'Name', 'PID', 'CPU (%)'} {'Name', 'PID', 'CPU (%)'}
@ -147,18 +147,18 @@ return function(update_freq)
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 * 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 end
-- For some reason this call is slow (querying anything with pstate in -- 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, -- general seems slow), but I also don't need to see an update every cycle,
-- hence the trigger -- hence the trigger
if trigger == 0 then 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 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 for r = 1, NUM_ROWS do
local pid = conky(TABLE_CONKY[r].pid, '(%d+)') -- may have leading spaces local pid = conky(TABLE_CONKY[r].pid, '(%d+)') -- may have leading spaces
@ -171,17 +171,17 @@ return function(update_freq)
end end
local draw_static = function(cr) local draw_static = function(cr)
Common.drawHeader(cr, header) common.drawHeader(cr, header)
for i = 1, #cores do 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) CompoundDial.draw_static(cores[i].loads, cr)
end end
Common.text_rows_draw_static(cpu_status, cr) common.text_rows_draw_static(cpu_status, cr)
Line.draw(separator, 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) Table.draw_static(tbl, cr)
end end
@ -189,11 +189,11 @@ return function(update_freq)
local draw_dynamic = function(cr) local draw_dynamic = function(cr)
for i = 1, #cores do for i = 1, #cores do
CompoundDial.draw_dynamic(cores[i].loads, cr) 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 end
Common.text_rows_draw_dynamic(cpu_status, cr) common.text_rows_draw_dynamic(cpu_status, cr)
Common.percent_plot_draw_dynamic(total_load, cr) common.percent_plot_draw_dynamic(total_load, cr)
Table.draw_dynamic(tbl, cr) Table.draw_dynamic(tbl, cr)
end end

View File

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

View File

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

View File

@ -1,23 +1,23 @@
local Util = require 'Util' local Util = require 'Util'
local Common = require 'Common' local common = require 'common'
local Geometry = require 'Geometry' local geometry = require 'geometry'
return function() return function()
local TEXT_SPACING = 20 local TEXT_SPACING = 20
local __string_match = string.match local __string_match = string.match
local header = Common.Header( local header = common.Header(
Geometry.LEFT_X, geometry.LEFT_X,
Geometry.TOP_Y, geometry.TOP_Y,
Geometry.SECTION_WIDTH, geometry.SECTION_WIDTH,
'SYSTEM' 'SYSTEM'
) )
local rows = Common.initTextRows( local rows = common.initTextRows(
Geometry.LEFT_X, geometry.LEFT_X,
header.bottom_y, header.bottom_y,
Geometry.SECTION_WIDTH, geometry.SECTION_WIDTH,
TEXT_SPACING, TEXT_SPACING,
{'Kernel', 'Uptime', 'Last Upgrade', 'Last Sync'} {'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]+).*") 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, Util.conky('$kernel'))
Common.text_rows_set(rows, 2, Util.conky('$uptime')) common.text_rows_set(rows, 2, Util.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
local draw_static = function(cr) local draw_static = function(cr)
Common.drawHeader(cr, header) common.drawHeader(cr, header)
Common.text_rows_draw_static(rows, cr) common.text_rows_draw_static(rows, cr)
end end
local draw_dynamic = function(cr) local draw_dynamic = function(cr)
Common.text_rows_draw_dynamic(rows, cr) common.text_rows_draw_dynamic(rows, cr)
end end
return {static = draw_static, dynamic = draw_dynamic, update = update} 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;' ABS_PATH..'core/widget/poly/?.lua;'
local Util = require 'Util' local Util = require 'Util'
local System = require 'System' local system = require 'system'
local Network = require 'Network' local network = require 'network'
local Processor = require 'Processor' local processor = require 'processor'
local FileSystem = require 'FileSystem' local filesystem = require 'filesystem'
local Pacman = require 'Pacman' local pacman = require 'pacman'
local Power = require 'Power' local power = require 'power'
local ReadWrite = require 'ReadWrite' local readwrite = require 'readwrite'
local Graphics = require 'Graphics' local graphics = require 'graphics'
local Memory = require 'Memory' local memory = require 'memory'
local Static = require 'Static' 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
@ -41,17 +41,17 @@ function conky_start(update_interval)
local update_freq = 1 / update_interval local update_freq = 1 / update_interval
local mem = Memory(update_freq) local mem = memory(update_freq)
local rw = ReadWrite(update_freq) local rw = readwrite(update_freq)
local net = Network(update_freq) local net = network(update_freq)
local pwr = Power(update_freq) local pwr = power(update_freq)
local fs = FileSystem() local fs = filesystem()
local sys = System() local sys = system()
local gfx = Graphics(update_freq) local gfx = graphics(update_freq)
local proc = Processor(update_freq) local proc = processor(update_freq)
local pcm = Pacman() local pcm = pacman()
local draw_static = Static( local draw_static = static(
{sys.static, gfx.static, proc.static}, {sys.static, gfx.static, proc.static},
{rw.static, net.static}, {rw.static, net.static},
{pcm.static, fs.static, pwr.static, mem.static} {pcm.static, fs.static, pwr.static, mem.static}