ENH move all geometry specs into the config.yaml file

This commit is contained in:
Nathan Dwarshuis 2022-07-17 12:40:36 -04:00
parent 9986969ed1
commit 6a49b2d2ce
12 changed files with 126 additions and 120 deletions

View File

@ -33,8 +33,16 @@ modules:
layout: layout:
anchor: [12, 11] anchor: [12, 11]
panels: panels:
- [[system, 19, graphics, 16, processor]] - columns:
- {blocks: [system, 19, graphics, 16, processor], width: 436}
margins: [20, 10]
- 10 - 10
- [[readwrite], 20, [network]] - columns:
- {blocks: [readwrite], width: 436}
- 20
- {blocks: [network], width: 436}
margins: [20, 10]
- 10 - 10
- [[pacman, 24, filesystem, 24, power, 19, memory]] - columns:
- {blocks: [pacman, 24, filesystem, 24, power, 19, memory], width: 436}
margins: [20, 10]

View File

@ -1,11 +1,10 @@
local i_o = require 'i_o' local i_o = require 'i_o'
local common = require 'common' local common = require 'common'
local geometry = require 'geometry'
local pure = require 'pure' local pure = require 'pure'
local impure = require 'impure' local impure = require 'impure'
-- ASSUME pathspecs will be at least 1 long -- ASSUME pathspecs will be at least 1 long
return function(config, main_state, point) return function(config, main_state, width, point)
local SPACING = 20 local SPACING = 20
local BAR_PAD = 100 local BAR_PAD = 100
local SEPARATOR_SPACING = 20 local SEPARATOR_SPACING = 20
@ -14,12 +13,7 @@ return function(config, main_state, point)
-- smartd -- smartd
local mk_smart = function(y) local mk_smart = function(y)
local obj = common.make_text_row( local obj = common.make_text_row(point.x, y, width, 'SMART Daemon')
point.x,
y,
geometry.SECTION_WIDTH,
'SMART Daemon'
)
local update = function() local update = function()
if main_state.trigger10 == 0 then if main_state.trigger10 == 0 then
local pid = i_o.execute_cmd('pidof smartd', nil, '*n') local pid = i_o.execute_cmd('pidof smartd', nil, '*n')
@ -27,7 +21,7 @@ return function(config, main_state, point)
end end
end end
return common.mk_acc( return common.mk_acc(
geometry.SECTION_WIDTH, width,
0, 0,
update, update,
pure.partial(common.text_row_draw_static, obj), pure.partial(common.text_row_draw_static, obj),
@ -35,11 +29,7 @@ return function(config, main_state, point)
) )
end end
local mk_sep = pure.partial( local mk_sep = pure.partial(common.mk_seperator, width, point.x)
common.mk_seperator,
geometry.SECTION_WIDTH,
point.x
)
----------------------------------------------------------------------------- -----------------------------------------------------------------------------
-- filesystem bar chart -- filesystem bar chart
@ -55,7 +45,7 @@ return function(config, main_state, point)
local obj = common.make_compound_bar( local obj = common.make_compound_bar(
point.x, point.x,
y, y,
geometry.SECTION_WIDTH, width,
BAR_PAD, BAR_PAD,
names, names,
SPACING, SPACING,
@ -71,7 +61,7 @@ return function(config, main_state, point)
end end
end end
return common.mk_acc( return common.mk_acc(
geometry.SECTION_WIDTH, width,
(#config.fs_paths - 1) * SPACING, (#config.fs_paths - 1) * SPACING,
update, update,
pure.partial(common.compound_bar_draw_static, obj), pure.partial(common.compound_bar_draw_static, obj),
@ -85,7 +75,7 @@ return function(config, main_state, point)
return common.reduce_blocks_( return common.reduce_blocks_(
'FILE SYSTEMS', 'FILE SYSTEMS',
point, point,
geometry.SECTION_WIDTH, width,
{{mk_smart, config.show_smart, SEPARATOR_SPACING}}, {{mk_smart, config.show_smart, SEPARATOR_SPACING}},
common.mk_section(SEPARATOR_SPACING, mk_sep, {mk_bars, true, 0}) common.mk_section(SEPARATOR_SPACING, mk_sep, {mk_bars, true, 0})
) )

View File

@ -1,9 +1,8 @@
local pure = require 'pure' local pure = require 'pure'
local i_o = require 'i_o' local i_o = require 'i_o'
local common = require 'common' local common = require 'common'
local geometry = require 'geometry'
return function(update_freq, config, point) return function(update_freq, config, width, point)
local SEPARATOR_SPACING = 20 local SEPARATOR_SPACING = 20
local TEXT_SPACING = 20 local TEXT_SPACING = 20
local PLOT_SEC_BREAK = 20 local PLOT_SEC_BREAK = 20
@ -29,7 +28,7 @@ return function(update_freq, config, point)
local obj = common.make_tagged_maybe_percent_timeseries( local obj = common.make_tagged_maybe_percent_timeseries(
point.x, point.x,
y, y,
geometry.SECTION_WIDTH, width,
PLOT_HEIGHT, PLOT_HEIGHT,
PLOT_SEC_BREAK, PLOT_SEC_BREAK,
label, label,
@ -43,7 +42,7 @@ return function(update_freq, config, point)
local static = pure.partial(common.tagged_percent_timeseries_draw_static, obj) local static = pure.partial(common.tagged_percent_timeseries_draw_static, obj)
local dynamic = pure.partial(common.tagged_percent_timeseries_draw_dynamic, obj) local dynamic = pure.partial(common.tagged_percent_timeseries_draw_dynamic, obj)
return common.mk_acc( return common.mk_acc(
geometry.SECTION_WIDTH, width,
PLOT_HEIGHT + PLOT_SEC_BREAK, PLOT_HEIGHT + PLOT_SEC_BREAK,
update, update,
static, static,
@ -58,7 +57,7 @@ return function(update_freq, config, point)
local obj = common.make_text_row( local obj = common.make_text_row(
point.x, point.x,
y, y,
geometry.SECTION_WIDTH, width,
'Status' 'Status'
) )
local update = function(s) local update = function(s)
@ -70,12 +69,12 @@ return function(update_freq, config, point)
end end
local static = pure.partial(common.text_row_draw_static, obj) local static = pure.partial(common.text_row_draw_static, obj)
local dynamic = pure.partial(common.text_row_draw_dynamic, obj) local dynamic = pure.partial(common.text_row_draw_dynamic, obj)
return common.mk_acc(geometry.SECTION_WIDTH, 0, update, static, dynamic) return common.mk_acc(width, 0, update, static, dynamic)
end end
local mk_sep = pure.partial( local mk_sep = pure.partial(
common.mk_seperator, common.mk_seperator,
geometry.SECTION_WIDTH, width,
point.x point.x
) )
@ -86,7 +85,7 @@ return function(update_freq, config, point)
local obj = common.make_threshold_text_row( local obj = common.make_threshold_text_row(
point.x, point.x,
y, y,
geometry.SECTION_WIDTH, 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
@ -100,7 +99,7 @@ return function(update_freq, config, point)
) )
local static = pure.partial(common.threshold_text_row_draw_static, obj) local static = pure.partial(common.threshold_text_row_draw_static, obj)
local dynamic = pure.partial(common.threshold_text_row_draw_dynamic, obj) local dynamic = pure.partial(common.threshold_text_row_draw_dynamic, obj)
return common.mk_acc(geometry.SECTION_WIDTH, 0, update, static, dynamic) return common.mk_acc(width, 0, update, static, dynamic)
end end
----------------------------------------------------------------------------- -----------------------------------------------------------------------------
@ -110,7 +109,7 @@ return function(update_freq, config, point)
local obj = common.make_text_rows( local obj = common.make_text_rows(
point.x, point.x,
y, y,
geometry.SECTION_WIDTH, width,
TEXT_SPACING, TEXT_SPACING,
{'GPU Clock Speed', 'memory Clock Speed'} {'GPU Clock Speed', 'memory Clock Speed'}
) )
@ -125,7 +124,7 @@ return function(update_freq, config, point)
end end
local static = pure.partial(common.text_rows_draw_static, obj) local static = pure.partial(common.text_rows_draw_static, obj)
local dynamic = pure.partial(common.text_rows_draw_dynamic, obj) local dynamic = pure.partial(common.text_rows_draw_dynamic, obj)
return common.mk_acc(geometry.SECTION_WIDTH, TEXT_SPACING, update, static, dynamic) return common.mk_acc(width, TEXT_SPACING, update, static, dynamic)
end end
----------------------------------------------------------------------------- -----------------------------------------------------------------------------
@ -220,7 +219,7 @@ return function(update_freq, config, point)
local rbs = common.reduce_blocks_( local rbs = common.reduce_blocks_(
'NVIDIA GRAPHICS', 'NVIDIA GRAPHICS',
point, point,
geometry.SECTION_WIDTH, width,
{{mk_status, true, SEPARATOR_SPACING}}, {{mk_status, true, SEPARATOR_SPACING}},
common.mk_section( common.mk_section(
SEPARATOR_SPACING, SEPARATOR_SPACING,

View File

@ -2,15 +2,9 @@ local timeseries = require 'timeseries'
local text_table = require 'text_table' local text_table = require 'text_table'
local i_o = require 'i_o' local i_o = require 'i_o'
local common = require 'common' local common = require 'common'
local geometry = require 'geometry'
local pure = require 'pure' local pure = require 'pure'
return function(update_freq, config, point) return function(update_freq, config, width, point)
-- local config = {
-- show_stats = true,
-- show_plot = true,
-- show_table = true,
-- }
local DIAL_THICKNESS = 8 local DIAL_THICKNESS = 8
local DIAL_RADIUS = 32 local DIAL_RADIUS = 32
local DIAL_SPACING = 40 local DIAL_SPACING = 40
@ -33,7 +27,7 @@ return function(update_freq, config, point)
local DIAL_DIAMETER = DIAL_RADIUS * 2 + DIAL_THICKNESS local DIAL_DIAMETER = DIAL_RADIUS * 2 + DIAL_THICKNESS
local SWAP_X = MEM_X + DIAL_DIAMETER + DIAL_SPACING local SWAP_X = MEM_X + DIAL_DIAMETER + DIAL_SPACING
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 = point.x + geometry.SECTION_WIDTH - CACHE_X local CACHE_WIDTH = point.x + width - CACHE_X
local format_percent = function(x) local format_percent = function(x)
return string.format('%i%%', x) return string.format('%i%%', x)
end end
@ -84,7 +78,7 @@ return function(update_freq, config, point)
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)
end end
return common.mk_acc(geometry.SECTION_WIDTH, DIAL_DIAMETER, update, static, dynamic) return common.mk_acc(width, DIAL_DIAMETER, update, static, dynamic)
end end
----------------------------------------------------------------------------- -----------------------------------------------------------------------------
@ -94,12 +88,12 @@ return function(update_freq, config, point)
local obj = common.make_percent_timeseries( local obj = common.make_percent_timeseries(
point.x, point.x,
y, y,
geometry.SECTION_WIDTH, width,
PLOT_HEIGHT, PLOT_HEIGHT,
update_freq update_freq
) )
return common.mk_acc( return common.mk_acc(
geometry.SECTION_WIDTH, width,
PLOT_HEIGHT, PLOT_HEIGHT,
function(s) timeseries.update(obj, s.mem.used_percent) end, function(s) timeseries.update(obj, s.mem.used_percent) end,
pure.partial(timeseries.draw_static, obj), pure.partial(timeseries.draw_static, obj),
@ -124,7 +118,7 @@ return function(update_freq, config, point)
local obj = common.make_text_table( local obj = common.make_text_table(
point.x, point.x,
y, y,
geometry.SECTION_WIDTH, width,
TABLE_HEIGHT, TABLE_HEIGHT,
NUM_ROWS, NUM_ROWS,
'Mem (%)' 'Mem (%)'
@ -137,7 +131,7 @@ return function(update_freq, config, point)
end end
end end
return common.mk_acc( return common.mk_acc(
geometry.SECTION_WIDTH, width,
TABLE_HEIGHT, TABLE_HEIGHT,
update, update,
pure.partial(text_table.draw_static, obj), pure.partial(text_table.draw_static, obj),
@ -188,7 +182,7 @@ return function(update_freq, config, point)
local rbs = common.reduce_blocks_( local rbs = common.reduce_blocks_(
'MEMORY', 'MEMORY',
point, point,
geometry.SECTION_WIDTH, width,
{ {
{mk_stats, config.show_stats, PLOT_SECTION_BREAK}, {mk_stats, config.show_stats, PLOT_SECTION_BREAK},
{mk_plot, config.show_plot, TABLE_SECTION_BREAK}, {mk_plot, config.show_plot, TABLE_SECTION_BREAK},

View File

@ -2,10 +2,9 @@ local format = require 'format'
local pure = require 'pure' local pure = require 'pure'
local i_o = require 'i_o' local i_o = require 'i_o'
local common = require 'common' local common = require 'common'
local geometry = require 'geometry'
local sys = require 'sys' local sys = require 'sys'
return function(update_freq, point) return function(update_freq, width, point)
local PLOT_SEC_BREAK = 20 local PLOT_SEC_BREAK = 20
local PLOT_HEIGHT = 56 local PLOT_HEIGHT = 56
local INTERFACE_PATHS = sys.get_net_interface_paths() local INTERFACE_PATHS = sys.get_net_interface_paths()
@ -42,7 +41,7 @@ return function(update_freq, point)
local obj = common.make_rate_timeseries( local obj = common.make_rate_timeseries(
point.x, point.x,
y, y,
geometry.SECTION_WIDTH, 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'),
@ -53,7 +52,7 @@ return function(update_freq, point)
state[key] state[key]
) )
return common.mk_acc( return common.mk_acc(
geometry.SECTION_WIDTH, width,
PLOT_HEIGHT + PLOT_SEC_BREAK, PLOT_HEIGHT + PLOT_SEC_BREAK,
function(s) common.update_rate_timeseries(obj, s[key]) end, function(s) common.update_rate_timeseries(obj, s[key]) end,
pure.partial(common.tagged_scaled_timeseries_draw_static, obj), pure.partial(common.tagged_scaled_timeseries_draw_static, obj),
@ -70,7 +69,7 @@ return function(update_freq, point)
local rbs = common.reduce_blocks_( local rbs = common.reduce_blocks_(
'NETWORK', 'NETWORK',
point, point,
geometry.SECTION_WIDTH, width,
{ {
{mk_rx, true, PLOT_SEC_BREAK}, {mk_rx, true, PLOT_SEC_BREAK},
{mk_tx, true, 0}, {mk_tx, true, 0},

View File

@ -1,8 +1,7 @@
local common = require 'common' local common = require 'common'
local pure = require 'pure' local pure = require 'pure'
local geometry = require 'geometry'
return function(main_state, point) return function(main_state, width, point)
local TEXT_SPACING = 20 local TEXT_SPACING = 20
local __string_match = string.match local __string_match = string.match
@ -12,7 +11,7 @@ return function(main_state, point)
local obj = common.make_text_rows( local obj = common.make_text_rows(
point.x, point.x,
y, y,
geometry.SECTION_WIDTH, width,
TEXT_SPACING, TEXT_SPACING,
{'Total', 'Explicit', 'Outdated', 'Orphaned', 'Local'} {'Total', 'Explicit', 'Outdated', 'Orphaned', 'Local'}
) )
@ -34,7 +33,7 @@ return function(main_state, point)
end end
end end
return common.mk_acc( return common.mk_acc(
geometry.SECTION_WIDTH, width,
TEXT_SPACING * 4, TEXT_SPACING * 4,
update, update,
pure.partial(common.text_rows_draw_static, obj), pure.partial(common.text_rows_draw_static, obj),
@ -45,7 +44,7 @@ return function(main_state, point)
return common.reduce_blocks_( return common.reduce_blocks_(
'PACMAN', 'PACMAN',
point, point,
geometry.SECTION_WIDTH, width,
{{mk_stats, true, 0}} {{mk_stats, true, 0}}
) )
end end

View File

@ -1,10 +1,9 @@
local format = require 'format' local format = require 'format'
local pure = require 'pure' local pure = require 'pure'
local common = require 'common' local common = require 'common'
local geometry = require 'geometry'
local sys = require 'sys' local sys = require 'sys'
return function(update_freq, config, point) return function(update_freq, config, width, point)
local TEXT_SPACING = 20 local TEXT_SPACING = 20
local PLOT_SEC_BREAK = 20 local PLOT_SEC_BREAK = 20
local PLOT_HEIGHT = 56 local PLOT_HEIGHT = 56
@ -31,7 +30,7 @@ return function(update_freq, config, point)
local obj = common.make_rate_timeseries( local obj = common.make_rate_timeseries(
point.x, point.x,
y, y,
geometry.SECTION_WIDTH, width,
PLOT_HEIGHT, PLOT_HEIGHT,
format_rapl, format_rapl,
power_label_function, power_label_function,
@ -42,7 +41,7 @@ return function(update_freq, config, point)
read_joules() read_joules()
) )
return common.mk_acc( return common.mk_acc(
geometry.SECTION_WIDTH, width,
PLOT_HEIGHT + PLOT_SEC_BREAK, PLOT_HEIGHT + PLOT_SEC_BREAK,
function(_) common.update_rate_timeseries(obj, read_joules()) end, function(_) common.update_rate_timeseries(obj, read_joules()) end,
mk_static(obj), mk_static(obj),
@ -81,7 +80,7 @@ return function(update_freq, config, point)
local obj = common.make_tagged_scaled_timeseries( local obj = common.make_tagged_scaled_timeseries(
point.x, point.x,
y, y,
geometry.SECTION_WIDTH, width,
PLOT_HEIGHT, PLOT_HEIGHT,
format_ac, format_ac,
power_label_function, power_label_function,
@ -91,7 +90,7 @@ return function(update_freq, config, point)
update_freq update_freq
) )
return common.mk_acc( return common.mk_acc(
geometry.SECTION_WIDTH, width,
PLOT_HEIGHT + PLOT_SEC_BREAK, PLOT_HEIGHT + PLOT_SEC_BREAK,
function() function()
common.tagged_scaled_timeseries_set( common.tagged_scaled_timeseries_set(
@ -110,7 +109,7 @@ return function(update_freq, config, point)
return common.reduce_blocks_( return common.reduce_blocks_(
'POWER', 'POWER',
point, point,
geometry.SECTION_WIDTH, width,
pure.concat( pure.concat(
pure.map(mk_rate_blockspec, config.rapl_specs), pure.map(mk_rate_blockspec, config.rapl_specs),
-- TODO what happens if this is nil? -- TODO what happens if this is nil?

View File

@ -2,13 +2,12 @@ local compound_dial = require 'compound_dial'
local text_table = require 'text_table' local text_table = require 'text_table'
local i_o = require 'i_o' local i_o = require 'i_o'
local common = require 'common' local common = require 'common'
local geometry = require 'geometry'
local cpu = require 'sys' local cpu = require 'sys'
local pure = require 'pure' local pure = require 'pure'
local __math_floor = math.floor local __math_floor = math.floor
return function(update_freq, config, main_state, point) return function(update_freq, config, main_state, width, point)
local DIAL_INNER_RADIUS = 30 local DIAL_INNER_RADIUS = 30
local DIAL_OUTER_RADIUS = 42 local DIAL_OUTER_RADIUS = 42
local DIAL_THICKNESS = 5.5 local DIAL_THICKNESS = 5.5
@ -63,7 +62,7 @@ return function(update_freq, config, main_state, point)
-- TODO what happens when the number of cores changes? -- TODO what happens when the number of cores changes?
for c = 1, ncores do for c = 1, ncores do
local dial_x = point.x + DIAL_OUTER_RADIUS + local dial_x = point.x + DIAL_OUTER_RADIUS +
(geometry.SECTION_WIDTH - 2 * DIAL_OUTER_RADIUS) * (c - 1) / 3 (width - 2 * DIAL_OUTER_RADIUS) * (c - 1) / 3
local dial_y = y + DIAL_OUTER_RADIUS local dial_y = y + DIAL_OUTER_RADIUS
cores[c] = create_core(dial_x, dial_y) cores[c] = create_core(dial_x, dial_y)
end end
@ -93,7 +92,7 @@ return function(update_freq, config, main_state, point)
end end
end end
return common.mk_acc( return common.mk_acc(
geometry.SECTION_WIDTH, width,
DIAL_OUTER_RADIUS * 2, DIAL_OUTER_RADIUS * 2,
update, update,
static, static,
@ -109,7 +108,7 @@ return function(update_freq, config, main_state, point)
local cpu_status = common.make_text_rows( local cpu_status = common.make_text_rows(
point.x, point.x,
y, y,
geometry.SECTION_WIDTH, width,
TEXT_SPACING, TEXT_SPACING,
{'HWP Preference', 'Ave Freq'} {'HWP Preference', 'Ave Freq'}
) )
@ -125,7 +124,7 @@ return function(update_freq, config, main_state, point)
local static = pure.partial(common.text_rows_draw_static, cpu_status) local static = pure.partial(common.text_rows_draw_static, cpu_status)
local dynamic = pure.partial(common.text_rows_draw_dynamic, cpu_status) local dynamic = pure.partial(common.text_rows_draw_dynamic, cpu_status)
return common.mk_acc( return common.mk_acc(
geometry.SECTION_WIDTH, width,
TEXT_SPACING, TEXT_SPACING,
update, update,
static, static,
@ -138,7 +137,7 @@ return function(update_freq, config, main_state, point)
local mk_sep = pure.partial( local mk_sep = pure.partial(
common.mk_seperator, common.mk_seperator,
geometry.SECTION_WIDTH, width,
point.x point.x
) )
@ -149,7 +148,7 @@ return function(update_freq, config, main_state, point)
local total_load = common.make_tagged_percent_timeseries( local total_load = common.make_tagged_percent_timeseries(
point.x, point.x,
y, y,
geometry.SECTION_WIDTH, width,
PLOT_HEIGHT, PLOT_HEIGHT,
PLOT_SECTION_BREAK, PLOT_SECTION_BREAK,
"Total Load", "Total Load",
@ -165,7 +164,7 @@ return function(update_freq, config, main_state, point)
local static = pure.partial(common.tagged_percent_timeseries_draw_static, total_load) local static = pure.partial(common.tagged_percent_timeseries_draw_static, total_load)
local dynamic = pure.partial(common.tagged_percent_timeseries_draw_dynamic, total_load) local dynamic = pure.partial(common.tagged_percent_timeseries_draw_dynamic, total_load)
return common.mk_acc( return common.mk_acc(
geometry.SECTION_WIDTH, width,
PLOT_HEIGHT + PLOT_SECTION_BREAK, PLOT_HEIGHT + PLOT_SECTION_BREAK,
update, update,
static, static,
@ -185,7 +184,7 @@ return function(update_freq, config, main_state, point)
local tbl = common.make_text_table( local tbl = common.make_text_table(
point.x, point.x,
y, y,
geometry.SECTION_WIDTH, width,
TABLE_HEIGHT, TABLE_HEIGHT,
NUM_ROWS, NUM_ROWS,
'CPU (%)' 'CPU (%)'
@ -204,7 +203,7 @@ return function(update_freq, config, main_state, point)
local static = pure.partial(text_table.draw_static, tbl) local static = pure.partial(text_table.draw_static, tbl)
local dynamic = pure.partial(text_table.draw_dynamic, tbl) local dynamic = pure.partial(text_table.draw_dynamic, tbl)
return common.mk_acc( return common.mk_acc(
geometry.SECTION_WIDTH, width,
TABLE_HEIGHT, TABLE_HEIGHT,
update, update,
static, static,
@ -218,7 +217,7 @@ return function(update_freq, config, main_state, point)
local rbs = common.reduce_blocks_( local rbs = common.reduce_blocks_(
'PROCESSOR', 'PROCESSOR',
point, point,
geometry.SECTION_WIDTH, width,
{ {
{mk_cores, config.show_cores, TEXT_SPACING}, {mk_cores, config.show_cores, TEXT_SPACING},
{mk_hwp_freq, config.show_stats, SEPARATOR_SPACING}, {mk_hwp_freq, config.show_stats, SEPARATOR_SPACING},

View File

@ -1,10 +1,9 @@
local format = require 'format' local format = require 'format'
local pure = require 'pure' local pure = require 'pure'
local common = require 'common' local common = require 'common'
local geometry = require 'geometry'
local sys = require 'sys' local sys = require 'sys'
return function(update_freq, config, point) return function(update_freq, config, width, point)
local PLOT_SEC_BREAK = 20 local PLOT_SEC_BREAK = 20
local PLOT_HEIGHT = 56 local PLOT_HEIGHT = 56
-- TODO currently this will find any block device -- TODO currently this will find any block device
@ -25,7 +24,7 @@ return function(update_freq, config, point)
local obj = common.make_rate_timeseries( local obj = common.make_rate_timeseries(
point.x, point.x,
y, y,
geometry.SECTION_WIDTH, 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'),
@ -37,7 +36,7 @@ return function(update_freq, config, point)
) )
return common.mk_acc( return common.mk_acc(
-- TODO construct this more sanely without referring to hardcoded vars -- TODO construct this more sanely without referring to hardcoded vars
geometry.SECTION_WIDTH, width,
PLOT_HEIGHT + PLOT_SEC_BREAK, PLOT_HEIGHT + PLOT_SEC_BREAK,
function() common.update_rate_timeseries(obj, state[key]) end, function() common.update_rate_timeseries(obj, state[key]) end,
pure.partial(common.tagged_scaled_timeseries_draw_static, obj), pure.partial(common.tagged_scaled_timeseries_draw_static, obj),
@ -54,7 +53,7 @@ return function(update_freq, config, point)
local rbs = common.reduce_blocks_( local rbs = common.reduce_blocks_(
'INPUT / OUTPUT', 'INPUT / OUTPUT',
point, point,
geometry.SECTION_WIDTH, width,
{ {
{mk_reads, true, PLOT_SEC_BREAK}, {mk_reads, true, PLOT_SEC_BREAK},
{mk_writes, true, 0}, {mk_writes, true, 0},

View File

@ -1,14 +1,13 @@
local common = require 'common' local common = require 'common'
local pure = require 'pure' local pure = require 'pure'
local geometry = require 'geometry'
local geom = require 'geom' local geom = require 'geom'
local fill_rect = require 'fill_rect' local fill_rect = require 'fill_rect'
local reduce_modules_y = function(modlist, init_x, acc, new) local reduce_modules_y = function(modlist, init_x, width, acc, new)
if type(new) == "number" then if type(new) == "number" then
acc.next_y = acc.next_y + new acc.next_y = acc.next_y + new
else else
local r = modlist[new](geom.make_point(init_x, acc.next_y)) local r = modlist[new](width, geom.make_point(init_x, acc.next_y))
table.insert(acc.fgroups, {update = r.update, static = r.static, dynamic = r.dynamic}) table.insert(acc.fgroups, {update = r.update, static = r.static, dynamic = r.dynamic})
acc.next_x = math.max(acc.next_x, r.next_x) acc.next_x = math.max(acc.next_x, r.next_x)
acc.next_y = r.next_y acc.next_y = r.next_y
@ -21,9 +20,9 @@ local reduce_modules_x = function(modlist, init_y, acc, x_mods)
acc.next_x = acc.next_x + x_mods acc.next_x = acc.next_x + x_mods
else else
local r = pure.reduce( local r = pure.reduce(
pure.partial(reduce_modules_y, modlist, acc.next_x), pure.partial(reduce_modules_y, modlist, acc.next_x, x_mods.width),
{next_x = acc.next_x, next_y = init_y, fgroups = acc.fgroups}, {next_x = acc.next_x, next_y = init_y, fgroups = acc.fgroups},
x_mods x_mods.blocks
) )
acc.fgroups = r.fgroups acc.fgroups = r.fgroups
acc.next_x = r.next_x acc.next_x = r.next_x
@ -72,14 +71,17 @@ local build_surface = function(box, fs)
return {x = cs_x, y = cs_y, s = cs} return {x = cs_x, y = cs_y, s = cs}
end end
local reduce_static = function(mods, y, margins, acc, panel_mods) local reduce_static = function(mods, y, acc, panel_mods)
if type(panel_mods) == "number" then if type(panel_mods) == "number" then
acc.next_x = acc.next_x + panel_mods acc.next_x = acc.next_x + panel_mods
else else
local mpoint = geom.make_point(acc.next_x + margins.x, y + margins.y) local margins = panel_mods.margins
local r = arrange_panel_modules(mods, mpoint, panel_mods) local margin_x = margins[1]
local w = r.width + margins.x * 2 local margin_y = margins[2]
local h = r.height + margins.y * 2 local mpoint = geom.make_point(acc.next_x + margin_x, y + margin_y)
local r = arrange_panel_modules(mods, mpoint, panel_mods.columns)
local w = r.width + margin_x * 2
local h = r.height + margin_y * 2
local pbox = geom.make_box(acc.next_x, y, w, h) local pbox = geom.make_box(acc.next_x, y, w, h)
acc.next_x = acc.next_x + w acc.next_x = acc.next_x + w
acc.static = pure.flatten({acc.static, {build_surface(pbox, r.static)}}) acc.static = pure.flatten({acc.static, {build_surface(pbox, r.static)}})
@ -97,8 +99,7 @@ return function(point, mods, module_sets)
pure.partial( pure.partial(
reduce_static, reduce_static,
mods, mods,
point.y, point.y
{x = geometry.PANEL_MARGIN_X, y = geometry.PANEL_MARGIN_Y}
), ),
{next_x = point.x, static = {}, update = {}, dynamic = {}}, {next_x = point.x, static = {}, update = {}, dynamic = {}},
module_sets module_sets

View File

@ -1,9 +1,8 @@
local i_o = require 'i_o' local i_o = require 'i_o'
local pure = require 'pure' local pure = require 'pure'
local common = require 'common' local common = require 'common'
local geometry = require 'geometry'
return function(main_state, point) return function(main_state, width, point)
local TEXT_SPACING = 20 local TEXT_SPACING = 20
local __string_match = string.match local __string_match = string.match
@ -12,7 +11,7 @@ return function(main_state, point)
local obj = common.make_text_rows( local obj = common.make_text_rows(
point.x, point.x,
y, y,
geometry.SECTION_WIDTH, width,
TEXT_SPACING, TEXT_SPACING,
{'Kernel', 'Uptime', 'Last Upgrade', 'Last Sync'} {'Kernel', 'Uptime', 'Last Upgrade', 'Last Sync'}
) )
@ -33,7 +32,7 @@ return function(main_state, point)
local static = pure.partial(common.text_rows_draw_static, obj) local static = pure.partial(common.text_rows_draw_static, obj)
local dynamic = pure.partial(common.text_rows_draw_dynamic, obj) local dynamic = pure.partial(common.text_rows_draw_dynamic, obj)
return common.mk_acc( return common.mk_acc(
geometry.SECTION_WIDTH, width,
TEXT_SPACING * 3, TEXT_SPACING * 3,
update, update,
static, static,
@ -44,7 +43,7 @@ return function(main_state, point)
return common.reduce_blocks_( return common.reduce_blocks_(
'SYSTEM', 'SYSTEM',
point, point,
geometry.SECTION_WIDTH, width,
{{mk_stats, true, 0}} {{mk_stats, true, 0}}
) )
end end

View File

@ -124,25 +124,45 @@ properties:
items: items:
type: integer type: integer
panels: panels:
description: either a panel (array) or padding between panels (int) description: either a panel (object) or padding between panels (int)
type: array type: array
items: items:
anyOf: anyOf:
- type: integer - type: integer
minimum: 0 minimum: 0
- type: array - type: object
description: layout for a single panel
required: [columns, margins]
additionalProperties: false
properties:
margins:
type: array
minItems: 2
maxItems: 2
items:
type: integer
columns:
description: | description: |
either a list of columns in a panel (array) or padding between either the columns in this panel (object) or padding
columns (int) between columns (int)
type: array
minItems: 1 minItems: 1
items: items:
anyOf: anyOf:
- type: integer - type: integer
minimum: 0 minimum: 0
- type: array - type: object
required: [blocks, width]
additionalProperties: false
properties:
width:
description: the width of all modules in this column
type: integer
minimum: 0
blocks:
description: | description: |
either a list of modules in a panel column (array) or either a module name (string) or padding (int)
padding between modules type: array
minItems: 1 minItems: 1
items: items:
anyOf: anyOf: