ENH use yaml theme instead of hardcoded theme
This commit is contained in:
parent
b657a60d1b
commit
0ae8e207f1
|
@ -69,8 +69,8 @@ theme:
|
||||||
- {stop: 1, color: 0x1e90ff}
|
- {stop: 1, color: 0x1e90ff}
|
||||||
fill:
|
fill:
|
||||||
gradient_alpha:
|
gradient_alpha:
|
||||||
- {stop: 0.2, color: 0x003f7c, alpha: 0.5}
|
- {stop: 0.2, color: 0x316ece, alpha: 0.5}
|
||||||
- {stop: 1, color: 0x1e90ff, alpha: 1.0}
|
- {stop: 1, color: 0x8cc7ff, alpha: 1.0}
|
||||||
indicator:
|
indicator:
|
||||||
bg:
|
bg:
|
||||||
gradient:
|
gradient:
|
||||||
|
|
|
@ -1,8 +1,7 @@
|
||||||
local M = {}
|
|
||||||
|
|
||||||
local geom = require 'geom'
|
local geom = require 'geom'
|
||||||
local format = require 'format'
|
local format = require 'format'
|
||||||
local theme = require 'theme'
|
local color = require 'color'
|
||||||
|
-- local theme = require 'theme'
|
||||||
local dial = require 'dial'
|
local dial = require 'dial'
|
||||||
local rect = require 'rect'
|
local rect = require 'rect'
|
||||||
local fill_rect = require 'fill_rect'
|
local fill_rect = require 'fill_rect'
|
||||||
|
@ -21,10 +20,47 @@ local style = require 'style'
|
||||||
local source = require 'source'
|
local source = require 'source'
|
||||||
local pure = require 'pure'
|
local pure = require 'pure'
|
||||||
|
|
||||||
--------------------------------------------------------------------------------
|
local compile_patterns
|
||||||
|
|
||||||
|
compile_patterns = function(patterns)
|
||||||
|
local r = {}
|
||||||
|
for k, v in pairs(patterns) do
|
||||||
|
if type(v) == "number" then
|
||||||
|
r[k] = color.rgb(v)
|
||||||
|
elseif v.color ~= nil then
|
||||||
|
r[k] = color.rgba(v.color, v.alpha)
|
||||||
|
elseif v.gradient ~= nil then
|
||||||
|
local p = {}
|
||||||
|
local g = v.gradient
|
||||||
|
for i = 1, #g do
|
||||||
|
local _g = g[i]
|
||||||
|
p[_g.stop] = _g.color
|
||||||
|
end
|
||||||
|
r[k] = color.gradient_rgb(p)
|
||||||
|
elseif v.gradient_alpha ~= nil then
|
||||||
|
local p = {}
|
||||||
|
local g = v.gradient_alpha
|
||||||
|
for i = 1, #g do
|
||||||
|
local _g = g[i]
|
||||||
|
p[_g.stop] = {_g.color, _g.alpha}
|
||||||
|
end
|
||||||
|
r[k] = color.gradient_rgba(p)
|
||||||
|
else
|
||||||
|
r[k] = compile_patterns(v)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
return r
|
||||||
|
end
|
||||||
|
|
||||||
|
return function(config)
|
||||||
|
local M = {}
|
||||||
|
|
||||||
|
local patterns = compile_patterns(config.theme.patterns)
|
||||||
|
|
||||||
|
-----------------------------------------------------------------------------
|
||||||
-- constants
|
-- constants
|
||||||
|
|
||||||
local FONT = 'Neuropolitical'
|
local FONT = config.theme.font
|
||||||
|
|
||||||
local NORMAL_FONT_SIZE = 13
|
local NORMAL_FONT_SIZE = 13
|
||||||
local PLOT_LABEL_FONT_SIZE = 8
|
local PLOT_LABEL_FONT_SIZE = 8
|
||||||
|
@ -53,14 +89,14 @@ local ARC_WIDTH = 2
|
||||||
local DIAL_THETA0 = 90
|
local DIAL_THETA0 = 90
|
||||||
local DIAL_THETA1 = 360
|
local DIAL_THETA1 = 360
|
||||||
|
|
||||||
--------------------------------------------------------------------------------
|
-----------------------------------------------------------------------------
|
||||||
-- line helper functions
|
-- line helper functions
|
||||||
|
|
||||||
local _make_horizontal_line = function(x, y, w)
|
local _make_horizontal_line = function(x, y, w)
|
||||||
return geom.make_line(geom.make_point(x, y), geom.make_point(x + w, y))
|
return geom.make_line(geom.make_point(x, y), geom.make_point(x + w, y))
|
||||||
end
|
end
|
||||||
|
|
||||||
--------------------------------------------------------------------------------
|
-----------------------------------------------------------------------------
|
||||||
-- text helper functions
|
-- text helper functions
|
||||||
|
|
||||||
local make_font_spec = function(f, size, bold)
|
local make_font_spec = function(f, size, bold)
|
||||||
|
@ -79,8 +115,8 @@ local _text_row_style = function(x_align, color)
|
||||||
return text.config(normal_font_spec, color, x_align, 'center')
|
return text.config(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', patterns.text.inactive)
|
||||||
local _right_text_style = _text_row_style('right', theme.PRIMARY_FG)
|
local _right_text_style = _text_row_style('right', patterns.text.active)
|
||||||
|
|
||||||
local _bare_text = function(pt, _text, _style)
|
local _bare_text = function(pt, _text, _style)
|
||||||
return text.make_plain(pt, _text, _style)
|
return text.make_plain(pt, _text, _style)
|
||||||
|
@ -94,20 +130,20 @@ local _right_text = function(pt, _text)
|
||||||
return _bare_text(pt, _text, _right_text_style)
|
return _bare_text(pt, _text, _right_text_style)
|
||||||
end
|
end
|
||||||
|
|
||||||
--------------------------------------------------------------------------------
|
-----------------------------------------------------------------------------
|
||||||
-- timeseries helper functions
|
-- timeseries helper functions
|
||||||
|
|
||||||
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
|
patterns.plot.grid
|
||||||
)
|
)
|
||||||
|
|
||||||
local _default_plot_config = timeseries.config(
|
local _default_plot_config = timeseries.config(
|
||||||
PLOT_NUM_POINTS,
|
PLOT_NUM_POINTS,
|
||||||
theme.PLOT_OUTLINE_FG,
|
patterns.plot.outline,
|
||||||
theme.PLOT_FILL_BORDER_PRIMARY,
|
patterns.plot.data.border,
|
||||||
theme.PLOT_FILL_BG_PRIMARY,
|
patterns.plot.data.fill,
|
||||||
_default_grid_config
|
_default_grid_config
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -120,7 +156,7 @@ local _format_percent_maybe = function(z)
|
||||||
end
|
end
|
||||||
|
|
||||||
local _percent_label_config = timeseries.label_config(
|
local _percent_label_config = timeseries.label_config(
|
||||||
theme.INACTIVE_TEXT_FG,
|
patterns.text.inactive,
|
||||||
label_font_spec,
|
label_font_spec,
|
||||||
_format_percent_label
|
_format_percent_label
|
||||||
)
|
)
|
||||||
|
@ -142,7 +178,7 @@ local _make_tagged_percent_timeseries = function(x, y, w, h, spacing, label, upd
|
||||||
nil,
|
nil,
|
||||||
_right_text_style,
|
_right_text_style,
|
||||||
_format,
|
_format,
|
||||||
text_threshold.config(theme.CRITICAL_FG, 80, false)
|
text_threshold.config(patterns.text.critical, 80, false)
|
||||||
),
|
),
|
||||||
plot = M.make_percent_timeseries(
|
plot = M.make_percent_timeseries(
|
||||||
x,
|
x,
|
||||||
|
@ -154,7 +190,7 @@ local _make_tagged_percent_timeseries = function(x, y, w, h, spacing, label, upd
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
--------------------------------------------------------------------------------
|
-----------------------------------------------------------------------------
|
||||||
-- scaled timeseries helper functions
|
-- scaled timeseries helper functions
|
||||||
|
|
||||||
local _base_2_scale_data = function(m)
|
local _base_2_scale_data = function(m)
|
||||||
|
@ -166,12 +202,12 @@ local _make_scaled_timeseries = function(x, y, w, h, f, min_domain, update_freq)
|
||||||
geom.make_box(x, y, w, h),
|
geom.make_box(x, y, w, h),
|
||||||
update_freq,
|
update_freq,
|
||||||
_default_plot_config,
|
_default_plot_config,
|
||||||
timeseries.label_config(theme.INACTIVE_TEXT_FG, label_font_spec, f),
|
timeseries.label_config(patterns.text.inactive, label_font_spec, f),
|
||||||
_base_2_scale_data(min_domain)
|
_base_2_scale_data(min_domain)
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
|
|
||||||
--------------------------------------------------------------------------------
|
-----------------------------------------------------------------------------
|
||||||
-- header
|
-- header
|
||||||
|
|
||||||
M.make_header = function(x, y, w, _text)
|
M.make_header = function(x, y, w, _text)
|
||||||
|
@ -183,7 +219,7 @@ M.make_header = function(x, y, w, _text)
|
||||||
_text,
|
_text,
|
||||||
text.config(
|
text.config(
|
||||||
make_font_spec(FONT, HEADER_FONT_SIZE, true),
|
make_font_spec(FONT, HEADER_FONT_SIZE, true),
|
||||||
theme.HEADER_FG,
|
patterns.header,
|
||||||
'left',
|
'left',
|
||||||
'top'
|
'top'
|
||||||
)
|
)
|
||||||
|
@ -193,7 +229,7 @@ M.make_header = function(x, y, w, _text)
|
||||||
_make_horizontal_line(x, underline_y, w),
|
_make_horizontal_line(x, underline_y, w),
|
||||||
line.config(
|
line.config(
|
||||||
style.line(HEADER_UNDERLINE_THICKNESS, HEADER_UNDERLINE_CAP),
|
style.line(HEADER_UNDERLINE_THICKNESS, HEADER_UNDERLINE_CAP),
|
||||||
theme.HEADER_FG,
|
patterns.header,
|
||||||
true
|
true
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
@ -205,14 +241,14 @@ M.draw_header = function(cr, header)
|
||||||
line.draw(header.underline, cr)
|
line.draw(header.underline, cr)
|
||||||
end
|
end
|
||||||
|
|
||||||
--------------------------------------------------------------------------------
|
-----------------------------------------------------------------------------
|
||||||
-- percent timeseries
|
-- percent timeseries
|
||||||
|
|
||||||
M.make_percent_timeseries = function(x, y, w, h, update_freq)
|
M.make_percent_timeseries = function(x, y, w, h, update_freq)
|
||||||
return _make_timeseries(x, y, w, h, _percent_label_config, update_freq)
|
return _make_timeseries(x, y, w, h, _percent_label_config, update_freq)
|
||||||
end
|
end
|
||||||
|
|
||||||
--------------------------------------------------------------------------------
|
-----------------------------------------------------------------------------
|
||||||
-- tagged percent timeseries
|
-- tagged percent timeseries
|
||||||
|
|
||||||
M.make_tagged_percent_timeseries = function(x, y, w, h, spacing, label, update_freq)
|
M.make_tagged_percent_timeseries = function(x, y, w, h, spacing, label, update_freq)
|
||||||
|
@ -252,7 +288,7 @@ M.tagged_maybe_percent_timeseries_set = function(obj, percent)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
--------------------------------------------------------------------------------
|
-----------------------------------------------------------------------------
|
||||||
-- scaled plot
|
-- scaled plot
|
||||||
|
|
||||||
-- Generate a format string for labels on y axis of plots. If the max of the
|
-- Generate a format string for labels on y axis of plots. If the max of the
|
||||||
|
@ -283,7 +319,7 @@ M.converted_y_label_format_generator = function(unit)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
--------------------------------------------------------------------------------
|
-----------------------------------------------------------------------------
|
||||||
-- tagged scaled plot
|
-- tagged scaled plot
|
||||||
|
|
||||||
M.make_tagged_scaled_timeseries = function(x, y, w, h, format_fun, label_fun,
|
M.make_tagged_scaled_timeseries = function(x, y, w, h, format_fun, label_fun,
|
||||||
|
@ -315,7 +351,7 @@ M.tagged_scaled_timeseries_set = function(asp, value)
|
||||||
scaled_timeseries.update(asp.plot, value)
|
scaled_timeseries.update(asp.plot, value)
|
||||||
end
|
end
|
||||||
|
|
||||||
--------------------------------------------------------------------------------
|
-----------------------------------------------------------------------------
|
||||||
-- rate timecourse plots
|
-- rate timecourse plots
|
||||||
|
|
||||||
local make_differential = function(update_frequency)
|
local make_differential = function(update_frequency)
|
||||||
|
@ -352,17 +388,17 @@ M.update_rate_timeseries = function(obj, value)
|
||||||
obj.prev_value = value
|
obj.prev_value = value
|
||||||
end
|
end
|
||||||
|
|
||||||
--------------------------------------------------------------------------------
|
-----------------------------------------------------------------------------
|
||||||
-- circle
|
-- circle
|
||||||
|
|
||||||
M.make_circle = function(x, y, r)
|
M.make_circle = function(x, y, r)
|
||||||
return circle.make(
|
return circle.make(
|
||||||
geom.make_circle(x, y, r),
|
geom.make_circle(x, y, r),
|
||||||
circle.config(style.line(ARC_WIDTH, CAIRO_LINE_CAP_BUTT), theme.BORDER_FG)
|
circle.config(style.line(ARC_WIDTH, CAIRO_LINE_CAP_BUTT), patterns.border)
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
|
|
||||||
--------------------------------------------------------------------------------
|
-----------------------------------------------------------------------------
|
||||||
-- ring with text data in the center
|
-- ring with text data in the center
|
||||||
|
|
||||||
M.make_text_circle = function(x, y, r, fmt, threshhold, pre_function)
|
M.make_text_circle = function(x, y, r, fmt, threshhold, pre_function)
|
||||||
|
@ -371,9 +407,9 @@ M.make_text_circle = function(x, y, r, fmt, threshhold, pre_function)
|
||||||
value = text_threshold.make_formatted(
|
value = text_threshold.make_formatted(
|
||||||
geom.make_point(x, y),
|
geom.make_point(x, y),
|
||||||
0,
|
0,
|
||||||
text.config(normal_font_spec, theme.PRIMARY_FG, 'center', 'center'),
|
text.config(normal_font_spec, patterns.text.active, 'center', 'center'),
|
||||||
fmt,
|
fmt,
|
||||||
text_threshold.config(theme.CRITICAL_FG, threshhold, pre_function)
|
text_threshold.config(patterns.text.critical, threshhold, pre_function)
|
||||||
),
|
),
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
@ -390,13 +426,13 @@ M.text_circle_set = function(tr, value)
|
||||||
text_threshold.set(tr.value, value)
|
text_threshold.set(tr.value, value)
|
||||||
end
|
end
|
||||||
|
|
||||||
--------------------------------------------------------------------------------
|
-----------------------------------------------------------------------------
|
||||||
-- dial
|
-- dial
|
||||||
|
|
||||||
local threshold_indicator = function(threshold)
|
local threshold_indicator = function(threshold)
|
||||||
return source.threshold_config(
|
return source.threshold_config(
|
||||||
theme.INDICATOR_FG_PRIMARY,
|
patterns.indicator.fg.active,
|
||||||
theme.INDICATOR_FG_CRITICAL,
|
patterns.indicator.fg.critical,
|
||||||
threshold
|
threshold
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
|
@ -405,7 +441,7 @@ M.make_dial = function(x, y, radius, thickness, threshold, _format, pre_function
|
||||||
return {
|
return {
|
||||||
dial = dial.make(
|
dial = dial.make(
|
||||||
geom.make_arc(x, y, radius, DIAL_THETA0, DIAL_THETA1),
|
geom.make_arc(x, y, radius, DIAL_THETA0, DIAL_THETA1),
|
||||||
arc.config(style.line(thickness, CAIRO_LINE_CAP_BUTT), theme.INDICATOR_BG),
|
arc.config(style.line(thickness, CAIRO_LINE_CAP_BUTT), patterns.indicator.bg),
|
||||||
threshold_indicator(threshold)
|
threshold_indicator(threshold)
|
||||||
),
|
),
|
||||||
text_circle = M.make_text_circle(x, y, radius - thickness / 2 - 2, _format, threshold, pre_function),
|
text_circle = M.make_text_circle(x, y, radius - thickness / 2 - 2, _format, threshold, pre_function),
|
||||||
|
@ -427,21 +463,21 @@ M.dial_draw_dynamic = function(dl, cr)
|
||||||
M.text_circle_draw_dynamic(dl.text_circle, cr)
|
M.text_circle_draw_dynamic(dl.text_circle, cr)
|
||||||
end
|
end
|
||||||
|
|
||||||
--------------------------------------------------------------------------------
|
-----------------------------------------------------------------------------
|
||||||
-- compound dial
|
-- compound dial
|
||||||
|
|
||||||
M.make_compound_dial = function(x, y, outer_radius, inner_radius, thickness,
|
M.make_compound_dial = function(x, y, outer_radius, inner_radius, thickness,
|
||||||
threshold, num_dials)
|
threshold, num_dials)
|
||||||
return compound_dial.make(
|
return compound_dial.make(
|
||||||
geom.make_arc(x, y, outer_radius, DIAL_THETA0, DIAL_THETA1),
|
geom.make_arc(x, y, outer_radius, DIAL_THETA0, DIAL_THETA1),
|
||||||
arc.config(style.line(thickness, CAIRO_LINE_CAP_BUTT), theme.INDICATOR_BG),
|
arc.config(style.line(thickness, CAIRO_LINE_CAP_BUTT), patterns.indicator.bg),
|
||||||
threshold_indicator(threshold),
|
threshold_indicator(threshold),
|
||||||
inner_radius,
|
inner_radius,
|
||||||
num_dials
|
num_dials
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
|
|
||||||
--------------------------------------------------------------------------------
|
-----------------------------------------------------------------------------
|
||||||
-- annotated compound bar
|
-- annotated compound bar
|
||||||
|
|
||||||
M.make_compound_bar = function(x, y, w, pad, labels, spacing, thickness, threshold)
|
M.make_compound_bar = function(x, y, w, pad, labels, spacing, thickness, threshold)
|
||||||
|
@ -458,7 +494,7 @@ M.make_compound_bar = function(x, y, w, pad, labels, spacing, thickness, thresho
|
||||||
w - pad,
|
w - pad,
|
||||||
line.config(
|
line.config(
|
||||||
style.line(thickness, CAIRO_LINE_CAP_BUTT),
|
style.line(thickness, CAIRO_LINE_CAP_BUTT),
|
||||||
theme.INDICATOR_BG,
|
patterns.indicator.bg,
|
||||||
true
|
true
|
||||||
),
|
),
|
||||||
threshold_indicator(threshold),
|
threshold_indicator(threshold),
|
||||||
|
@ -482,7 +518,7 @@ M.compound_bar_set = function(cb, i, value)
|
||||||
compound_bar.set(cb.bars, i, value)
|
compound_bar.set(cb.bars, i, value)
|
||||||
end
|
end
|
||||||
|
|
||||||
--------------------------------------------------------------------------------
|
-----------------------------------------------------------------------------
|
||||||
-- separator (eg a horizontal line)
|
-- separator (eg a horizontal line)
|
||||||
|
|
||||||
M.make_separator = function(x, y, w)
|
M.make_separator = function(x, y, w)
|
||||||
|
@ -490,13 +526,13 @@ M.make_separator = function(x, y, w)
|
||||||
_make_horizontal_line(x, y, w),
|
_make_horizontal_line(x, y, w),
|
||||||
line.config(
|
line.config(
|
||||||
style.line(SEPARATOR_THICKNESS, CAIRO_LINE_CAP_BUTT),
|
style.line(SEPARATOR_THICKNESS, CAIRO_LINE_CAP_BUTT),
|
||||||
theme.BORDER_FG,
|
patterns.border,
|
||||||
true
|
true
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
|
|
||||||
--------------------------------------------------------------------------------
|
-----------------------------------------------------------------------------
|
||||||
-- text row (label with a value, aligned as far apart as possible)
|
-- text row (label with a value, aligned as far apart as possible)
|
||||||
|
|
||||||
M.make_text_row = function(x, y, w, label)
|
M.make_text_row = function(x, y, w, label)
|
||||||
|
@ -518,7 +554,7 @@ M.text_row_set = function(row, value)
|
||||||
text.set(row.value, value)
|
text.set(row.value, value)
|
||||||
end
|
end
|
||||||
|
|
||||||
--------------------------------------------------------------------------------
|
-----------------------------------------------------------------------------
|
||||||
-- text row with critical indicator
|
-- text row with critical indicator
|
||||||
|
|
||||||
M.make_threshold_text_row = function(x, y, w, label, append_end, limit)
|
M.make_threshold_text_row = function(x, y, w, label, append_end, limit)
|
||||||
|
@ -529,7 +565,7 @@ M.make_threshold_text_row = function(x, y, w, label, append_end, limit)
|
||||||
nil,
|
nil,
|
||||||
_right_text_style,
|
_right_text_style,
|
||||||
append_end,
|
append_end,
|
||||||
text_threshold.config(theme.CRITICAL_FG, limit, false)
|
text_threshold.config(patterns.text.critical, limit, false)
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
@ -544,7 +580,7 @@ M.threshold_text_row_set = function(row, value)
|
||||||
text_threshold.set(row.value, value)
|
text_threshold.set(row.value, value)
|
||||||
end
|
end
|
||||||
|
|
||||||
--------------------------------------------------------------------------------
|
-----------------------------------------------------------------------------
|
||||||
-- multiple text row separated by spacing
|
-- multiple text row separated by spacing
|
||||||
|
|
||||||
M.make_text_rows_formatted = function(x, y, w, spacing, labels, format)
|
M.make_text_rows_formatted = function(x, y, w, spacing, labels, format)
|
||||||
|
@ -590,7 +626,7 @@ M.text_rows_set = function(rows, i, value)
|
||||||
text_column.set(rows.values, i, value)
|
text_column.set(rows.values, i, value)
|
||||||
end
|
end
|
||||||
|
|
||||||
--------------------------------------------------------------------------------
|
-----------------------------------------------------------------------------
|
||||||
-- table
|
-- table
|
||||||
|
|
||||||
local default_table_font_spec = make_font_spec(FONT, TABLE_FONT_SIZE, false)
|
local default_table_font_spec = make_font_spec(FONT, TABLE_FONT_SIZE, false)
|
||||||
|
@ -599,21 +635,21 @@ local default_table_config = function(label)
|
||||||
return tbl.config(
|
return tbl.config(
|
||||||
rect.config(
|
rect.config(
|
||||||
style.closed_poly(TABLE_LINE_THICKNESS, CAIRO_LINE_JOIN_MITER),
|
style.closed_poly(TABLE_LINE_THICKNESS, CAIRO_LINE_JOIN_MITER),
|
||||||
theme.BORDER_FG
|
patterns.border
|
||||||
),
|
),
|
||||||
line.config(
|
line.config(
|
||||||
style.line(TABLE_LINE_THICKNESS, CAIRO_LINE_CAP_BUTT),
|
style.line(TABLE_LINE_THICKNESS, CAIRO_LINE_CAP_BUTT),
|
||||||
theme.BORDER_FG,
|
patterns.border,
|
||||||
true
|
true
|
||||||
),
|
),
|
||||||
tbl.header_config(
|
tbl.header_config(
|
||||||
default_table_font_spec,
|
default_table_font_spec,
|
||||||
theme.PRIMARY_FG,
|
patterns.text.active,
|
||||||
TABLE_HEADER_PAD
|
TABLE_HEADER_PAD
|
||||||
),
|
),
|
||||||
tbl.body_config(
|
tbl.body_config(
|
||||||
default_table_font_spec,
|
default_table_font_spec,
|
||||||
theme.INACTIVE_TEXT_FG,
|
patterns.text.inactive,
|
||||||
{
|
{
|
||||||
tbl.column_config('Name', TABLE_BODY_FORMAT),
|
tbl.column_config('Name', TABLE_BODY_FORMAT),
|
||||||
tbl.column_config('PID', false),
|
tbl.column_config('PID', false),
|
||||||
|
@ -637,7 +673,7 @@ M.make_text_table = function(x, y, w, h, n, label)
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
|
|
||||||
--------------------------------------------------------------------------------
|
-----------------------------------------------------------------------------
|
||||||
-- panel
|
-- panel
|
||||||
|
|
||||||
M.make_panel = function(x, y, w, h, thickness)
|
M.make_panel = function(x, y, w, h, thickness)
|
||||||
|
@ -645,98 +681,11 @@ M.make_panel = function(x, y, w, h, thickness)
|
||||||
geom.make_box(x, y, w, h),
|
geom.make_box(x, y, w, h),
|
||||||
rect.config(
|
rect.config(
|
||||||
style.closed_poly(thickness, CAIRO_LINE_JOIN_MITER),
|
style.closed_poly(thickness, CAIRO_LINE_JOIN_MITER),
|
||||||
theme.BORDER_FG
|
patterns.border
|
||||||
),
|
),
|
||||||
theme.PANEL_BG
|
patterns.panel
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
|
|
||||||
--------------------------------------------------------------------------------
|
|
||||||
-- setup functions
|
|
||||||
|
|
||||||
local _combine_blocks = function(acc, new)
|
|
||||||
if new.active == true then
|
|
||||||
local n = new.f(acc.next_y)
|
|
||||||
table.insert(acc.objs, n.obj)
|
|
||||||
acc.w = math.max(acc.w, n.w)
|
|
||||||
acc.final_y = acc.next_y + n.h
|
|
||||||
acc.next_y = acc.final_y + new.offset
|
|
||||||
end
|
|
||||||
return acc
|
|
||||||
end
|
|
||||||
|
|
||||||
local non_false = function(xs)
|
|
||||||
return pure.filter(function(x) return x ~= false end, xs)
|
|
||||||
end
|
|
||||||
|
|
||||||
local active_blocks = function(blockspecs)
|
|
||||||
local bs = pure.filter(function(b) return b[2] end, blockspecs)
|
|
||||||
return pure.map(function(b) return M.mk_block(table.unpack(b)) end, bs)
|
|
||||||
end
|
|
||||||
|
|
||||||
local flatten_sections = function(top, ...)
|
|
||||||
local f = function(acc, new)
|
|
||||||
if #new.blocks == 0 then
|
|
||||||
return acc
|
|
||||||
elseif #acc == 0 then
|
|
||||||
return new.blocks
|
|
||||||
else
|
|
||||||
return pure.flatten(
|
|
||||||
{acc, {M.mk_block(new.sep_fun, true, new.top)}, new.blocks}
|
|
||||||
)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
return pure.reduce(f, active_blocks(top), {...})
|
|
||||||
end
|
|
||||||
|
|
||||||
M.reduce_blocks_ = function(header, point, width, top_blocks, ...)
|
|
||||||
local mk_header = function(y)
|
|
||||||
local obj = M.make_header(point.x, y, width, header)
|
|
||||||
return M.mk_acc_static(
|
|
||||||
width,
|
|
||||||
obj.bottom_y - y,
|
|
||||||
function(cr) M.draw_header(cr, obj) end
|
|
||||||
)
|
|
||||||
end
|
|
||||||
local blocks = flatten_sections(top_blocks, ...)
|
|
||||||
local r = pure.reduce(
|
|
||||||
_combine_blocks,
|
|
||||||
{w = 0, next_y = point.y, final_y = point.y, objs = {}},
|
|
||||||
{M.mk_block(mk_header, true, 0), table.unpack(blocks)}
|
|
||||||
)
|
|
||||||
local us, ss, ds = table.unpack(pure.unzip(r.objs))
|
|
||||||
return {
|
|
||||||
next_x = point.x + r.w,
|
|
||||||
next_y = r.final_y,
|
|
||||||
update = pure.sequence(table.unpack(non_false(us))),
|
|
||||||
static = pure.sequence(table.unpack(ss)),
|
|
||||||
dynamic = pure.sequence(table.unpack(non_false(ds)))
|
|
||||||
}
|
|
||||||
end
|
|
||||||
|
|
||||||
M.mk_acc = function(w, h, u, s, d)
|
|
||||||
return {w = w, h = h, obj = {u, s, d}}
|
|
||||||
end
|
|
||||||
|
|
||||||
M.mk_acc_static = function(w, h, s)
|
|
||||||
return M.mk_acc(w, h, false, s, false)
|
|
||||||
end
|
|
||||||
|
|
||||||
M.mk_block = function(f, active, offset)
|
|
||||||
return {f = f, active = active, offset = offset}
|
|
||||||
end
|
|
||||||
|
|
||||||
M.mk_section = function(top, sep_fun, ...)
|
|
||||||
return {
|
|
||||||
top = top,
|
|
||||||
sep_fun = sep_fun,
|
|
||||||
blocks = active_blocks({...})
|
|
||||||
}
|
|
||||||
end
|
|
||||||
|
|
||||||
M.mk_seperator = function(width, x, y)
|
|
||||||
local separator = M.make_separator(x, y, width)
|
|
||||||
return M.mk_acc_static(width, 0, pure.partial(line.draw, separator))
|
|
||||||
end
|
|
||||||
|
|
||||||
return M
|
return M
|
||||||
|
end
|
||||||
|
|
|
@ -0,0 +1,218 @@
|
||||||
|
local M = {}
|
||||||
|
|
||||||
|
local pure = require 'pure'
|
||||||
|
local geom = require 'geom'
|
||||||
|
local fill_rect = require 'fill_rect'
|
||||||
|
local line = require 'line'
|
||||||
|
|
||||||
|
--------------------------------------------------------------------------------
|
||||||
|
-- compile individual module
|
||||||
|
|
||||||
|
local _combine_blocks = function(acc, new)
|
||||||
|
if new.active == true then
|
||||||
|
local n = new.f(acc.next_y)
|
||||||
|
table.insert(acc.objs, n.obj)
|
||||||
|
acc.w = math.max(acc.w, n.w)
|
||||||
|
acc.final_y = acc.next_y + n.h
|
||||||
|
acc.next_y = acc.final_y + new.offset
|
||||||
|
end
|
||||||
|
return acc
|
||||||
|
end
|
||||||
|
|
||||||
|
local non_false = function(xs)
|
||||||
|
return pure.filter(function(x) return x ~= false end, xs)
|
||||||
|
end
|
||||||
|
|
||||||
|
local mk_block = function(f, active, offset)
|
||||||
|
return {f = f, active = active, offset = offset}
|
||||||
|
end
|
||||||
|
|
||||||
|
local active_blocks = function(blockspecs)
|
||||||
|
local bs = pure.filter(function(b) return b[2] end, blockspecs)
|
||||||
|
return pure.map(function(b) return mk_block(table.unpack(b)) end, bs)
|
||||||
|
end
|
||||||
|
|
||||||
|
local flatten_sections = function(top, ...)
|
||||||
|
local f = function(acc, new)
|
||||||
|
if #new.blocks == 0 then
|
||||||
|
return acc
|
||||||
|
elseif #acc == 0 then
|
||||||
|
return new.blocks
|
||||||
|
else
|
||||||
|
return pure.flatten(
|
||||||
|
{acc, {mk_block(new.sep_fun, true, new.top)}, new.blocks}
|
||||||
|
)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
return pure.reduce(f, active_blocks(top), {...})
|
||||||
|
end
|
||||||
|
|
||||||
|
M.mk_section = function(top, sep_fun, ...)
|
||||||
|
return {
|
||||||
|
top = top,
|
||||||
|
sep_fun = sep_fun,
|
||||||
|
blocks = active_blocks({...})
|
||||||
|
}
|
||||||
|
end
|
||||||
|
|
||||||
|
M.mk_seperator = function(common, width, x, y)
|
||||||
|
local separator = common.make_separator(x, y, width)
|
||||||
|
return M.mk_acc_static(width, 0, pure.partial(line.draw, separator))
|
||||||
|
end
|
||||||
|
|
||||||
|
M.mk_acc = function(w, h, u, s, d)
|
||||||
|
return {w = w, h = h, obj = {u, s, d}}
|
||||||
|
end
|
||||||
|
|
||||||
|
M.mk_acc_static = function(w, h, s)
|
||||||
|
return M.mk_acc(w, h, false, s, false)
|
||||||
|
end
|
||||||
|
|
||||||
|
M.compile_module = function(common, header, point, width, top_blocks, ...)
|
||||||
|
local mk_header = function(y)
|
||||||
|
local obj = common.make_header(point.x, y, width, header)
|
||||||
|
return M.mk_acc_static(
|
||||||
|
width,
|
||||||
|
obj.bottom_y - y,
|
||||||
|
function(cr) common.draw_header(cr, obj) end
|
||||||
|
)
|
||||||
|
end
|
||||||
|
local blocks = flatten_sections(top_blocks, ...)
|
||||||
|
local r = pure.reduce(
|
||||||
|
_combine_blocks,
|
||||||
|
{w = 0, next_y = point.y, final_y = point.y, objs = {}},
|
||||||
|
{mk_block(mk_header, true, 0), table.unpack(blocks)}
|
||||||
|
)
|
||||||
|
local us, ss, ds = table.unpack(pure.unzip(r.objs))
|
||||||
|
return {
|
||||||
|
next_x = point.x + r.w,
|
||||||
|
next_y = r.final_y,
|
||||||
|
update = pure.sequence(table.unpack(non_false(us))),
|
||||||
|
static = pure.sequence(table.unpack(ss)),
|
||||||
|
dynamic = pure.sequence(table.unpack(non_false(ds)))
|
||||||
|
}
|
||||||
|
end
|
||||||
|
|
||||||
|
--------------------------------------------------------------------------------
|
||||||
|
-- compile entire layout
|
||||||
|
|
||||||
|
local reduce_modules_y = function(common, modlist, init_x, width, acc, new)
|
||||||
|
if type(new) == "number" then
|
||||||
|
acc.next_y = acc.next_y + new
|
||||||
|
else
|
||||||
|
print(new)
|
||||||
|
local r = modlist[new](common, width, geom.make_point(init_x, acc.next_y))
|
||||||
|
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_y = r.next_y
|
||||||
|
end
|
||||||
|
return acc
|
||||||
|
end
|
||||||
|
|
||||||
|
local reduce_modules_x = function(common, modlist, init_y, acc, x_mods)
|
||||||
|
if type(x_mods) == "number" then
|
||||||
|
acc.next_x = acc.next_x + x_mods
|
||||||
|
else
|
||||||
|
local r = pure.reduce(
|
||||||
|
pure.partial(reduce_modules_y, common, modlist, acc.next_x, x_mods.width),
|
||||||
|
{next_x = acc.next_x, next_y = init_y, fgroups = acc.fgroups},
|
||||||
|
x_mods.blocks
|
||||||
|
)
|
||||||
|
acc.fgroups = r.fgroups
|
||||||
|
acc.next_x = r.next_x
|
||||||
|
acc.next_y = math.max(acc.next_y, r.next_y)
|
||||||
|
end
|
||||||
|
return acc
|
||||||
|
end
|
||||||
|
|
||||||
|
local arrange_panel_modules = function(common, modlist, point, mods)
|
||||||
|
local r = pure.reduce(
|
||||||
|
pure.partial(reduce_modules_x, common, modlist, point.y),
|
||||||
|
{next_x = point.x, next_y = point.y, fgroups = {}},
|
||||||
|
mods
|
||||||
|
)
|
||||||
|
return {
|
||||||
|
point_ul = point,
|
||||||
|
width = r.next_x - point.x,
|
||||||
|
height = r.next_y - point.y,
|
||||||
|
update = pure.map_keys('update', r.fgroups),
|
||||||
|
static = pure.map_keys('static', r.fgroups),
|
||||||
|
dynamic = pure.map_keys('dynamic', r.fgroups),
|
||||||
|
}
|
||||||
|
end
|
||||||
|
|
||||||
|
local build_surface = function(common, box, fs)
|
||||||
|
local panel_line_thickness = 1
|
||||||
|
-- move over by half a pixel so the lines don't need to be antialiased
|
||||||
|
local _x = box.corner.x + 0.5
|
||||||
|
local _y = box.corner.y + 0.5
|
||||||
|
local panel = common.make_panel(_x, _y, box.width, box.height, panel_line_thickness)
|
||||||
|
local cs_x = _x - panel_line_thickness * 0.5
|
||||||
|
local cs_y = _y - panel_line_thickness * 0.5
|
||||||
|
local cs_w = box.width + panel_line_thickness
|
||||||
|
local cs_h = box.height + panel_line_thickness
|
||||||
|
|
||||||
|
local cs = cairo_image_surface_create(CAIRO_FORMAT_ARGB32, cs_w, cs_h)
|
||||||
|
local cr = cairo_create(cs)
|
||||||
|
|
||||||
|
cairo_translate(cr, -cs_x, -cs_y)
|
||||||
|
|
||||||
|
fill_rect.draw(panel, cr)
|
||||||
|
for i = 1, #fs do
|
||||||
|
fs[i](cr)
|
||||||
|
end
|
||||||
|
cairo_destroy(cr)
|
||||||
|
return {x = cs_x, y = cs_y, s = cs}
|
||||||
|
end
|
||||||
|
|
||||||
|
local reduce_static = function(common, mods, y, acc, panel_mods)
|
||||||
|
if type(panel_mods) == "number" then
|
||||||
|
acc.next_x = acc.next_x + panel_mods
|
||||||
|
else
|
||||||
|
local margins = panel_mods.margins
|
||||||
|
local margin_x = margins[1]
|
||||||
|
local margin_y = margins[2]
|
||||||
|
local mpoint = geom.make_point(acc.next_x + margin_x, y + margin_y)
|
||||||
|
local r = arrange_panel_modules(common, 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)
|
||||||
|
acc.next_x = acc.next_x + w
|
||||||
|
acc.static = pure.flatten({acc.static, {build_surface(common, pbox, r.static)}})
|
||||||
|
acc.update = pure.flatten({acc.update, r.update})
|
||||||
|
acc.dynamic = pure.flatten({acc.dynamic, r.dynamic})
|
||||||
|
end
|
||||||
|
return acc
|
||||||
|
end
|
||||||
|
|
||||||
|
M.compile_layout = function(common, point, mods, module_sets)
|
||||||
|
local __cairo_set_source_surface = cairo_set_source_surface
|
||||||
|
local __cairo_paint = cairo_paint
|
||||||
|
|
||||||
|
local r = pure.reduce(
|
||||||
|
pure.partial(
|
||||||
|
reduce_static,
|
||||||
|
common,
|
||||||
|
mods,
|
||||||
|
point.y
|
||||||
|
),
|
||||||
|
{next_x = point.x, static = {}, update = {}, dynamic = {}},
|
||||||
|
module_sets
|
||||||
|
)
|
||||||
|
|
||||||
|
local cs = r.static
|
||||||
|
|
||||||
|
return {
|
||||||
|
static = function(cr)
|
||||||
|
for i = 1, #cs do
|
||||||
|
local c = cs[i]
|
||||||
|
__cairo_set_source_surface(cr, c.s, c.x, c.y)
|
||||||
|
__cairo_paint(cr)
|
||||||
|
end
|
||||||
|
end,
|
||||||
|
update = pure.sequence(table.unpack(r.update)),
|
||||||
|
dynamic = pure.sequence(table.unpack(r.dynamic)),
|
||||||
|
}
|
||||||
|
end
|
||||||
|
|
||||||
|
return M
|
|
@ -1,10 +1,9 @@
|
||||||
local i_o = require 'i_o'
|
local i_o = require 'i_o'
|
||||||
local common = require 'common'
|
local compile = require 'compile'
|
||||||
local pure = require 'pure'
|
local pure = require 'pure'
|
||||||
local impure = require 'impure'
|
local impure = require 'impure'
|
||||||
|
|
||||||
-- ASSUME pathspecs will be at least 1 long
|
return function(config, main_state, common, width, 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
|
||||||
|
@ -20,7 +19,7 @@ return function(config, main_state, width, point)
|
||||||
common.text_row_set(obj, (pid == '') and 'Error' or 'Running')
|
common.text_row_set(obj, (pid == '') and 'Error' or 'Running')
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
return common.mk_acc(
|
return compile.mk_acc(
|
||||||
width,
|
width,
|
||||||
0,
|
0,
|
||||||
update,
|
update,
|
||||||
|
@ -29,7 +28,7 @@ return function(config, main_state, width, point)
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
|
|
||||||
local mk_sep = pure.partial(common.mk_seperator, width, point.x)
|
local mk_sep = pure.partial(compile.mk_seperator, common, width, point.x)
|
||||||
|
|
||||||
-----------------------------------------------------------------------------
|
-----------------------------------------------------------------------------
|
||||||
-- filesystem bar chart
|
-- filesystem bar chart
|
||||||
|
@ -37,7 +36,6 @@ return function(config, main_state, width, point)
|
||||||
local mk_bars = function(y)
|
local mk_bars = function(y)
|
||||||
local paths = pure.map_keys('path', config.fs_paths)
|
local paths = pure.map_keys('path', config.fs_paths)
|
||||||
local names = pure.map_keys('name', config.fs_paths)
|
local names = pure.map_keys('name', config.fs_paths)
|
||||||
-- local paths, names = table.unpack(pure.unzip(config.fs_paths))
|
|
||||||
local CONKY_CMDS = pure.map(
|
local CONKY_CMDS = pure.map(
|
||||||
pure.partial(string.format, '${fs_used_perc %s}', true),
|
pure.partial(string.format, '${fs_used_perc %s}', true),
|
||||||
paths
|
paths
|
||||||
|
@ -60,7 +58,7 @@ return function(config, main_state, width, point)
|
||||||
impure.ieach(read_fs, CONKY_CMDS)
|
impure.ieach(read_fs, CONKY_CMDS)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
return common.mk_acc(
|
return compile.mk_acc(
|
||||||
width,
|
width,
|
||||||
(#config.fs_paths - 1) * SPACING,
|
(#config.fs_paths - 1) * SPACING,
|
||||||
update,
|
update,
|
||||||
|
@ -72,11 +70,12 @@ return function(config, main_state, width, point)
|
||||||
-----------------------------------------------------------------------------
|
-----------------------------------------------------------------------------
|
||||||
-- main functions
|
-- main functions
|
||||||
|
|
||||||
return common.reduce_blocks_(
|
return compile.compile_module(
|
||||||
|
common,
|
||||||
'FILE SYSTEMS',
|
'FILE SYSTEMS',
|
||||||
point,
|
point,
|
||||||
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})
|
compile.mk_section(SEPARATOR_SPACING, mk_sep, {mk_bars, true, 0})
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,8 +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 compile = require 'compile'
|
||||||
|
|
||||||
return function(update_freq, config, width, point)
|
return function(update_freq, config, common, 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
|
||||||
|
@ -41,7 +41,7 @@ return function(update_freq, config, width, 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 compile.mk_acc(
|
||||||
width,
|
width,
|
||||||
PLOT_HEIGHT + PLOT_SEC_BREAK,
|
PLOT_HEIGHT + PLOT_SEC_BREAK,
|
||||||
update,
|
update,
|
||||||
|
@ -69,11 +69,12 @@ return function(update_freq, config, width, 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(width, 0, update, static, dynamic)
|
return compile.mk_acc(width, 0, update, static, dynamic)
|
||||||
end
|
end
|
||||||
|
|
||||||
local mk_sep = pure.partial(
|
local mk_sep = pure.partial(
|
||||||
common.mk_seperator,
|
compile.mk_seperator,
|
||||||
|
common,
|
||||||
width,
|
width,
|
||||||
point.x
|
point.x
|
||||||
)
|
)
|
||||||
|
@ -99,7 +100,7 @@ return function(update_freq, config, width, 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(width, 0, update, static, dynamic)
|
return compile.mk_acc(width, 0, update, static, dynamic)
|
||||||
end
|
end
|
||||||
|
|
||||||
-----------------------------------------------------------------------------
|
-----------------------------------------------------------------------------
|
||||||
|
@ -124,7 +125,7 @@ return function(update_freq, config, width, 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(width, TEXT_SPACING, update, static, dynamic)
|
return compile.mk_acc(width, TEXT_SPACING, update, static, dynamic)
|
||||||
end
|
end
|
||||||
|
|
||||||
-----------------------------------------------------------------------------
|
-----------------------------------------------------------------------------
|
||||||
|
@ -216,22 +217,23 @@ return function(update_freq, config, width, point)
|
||||||
-----------------------------------------------------------------------------
|
-----------------------------------------------------------------------------
|
||||||
-- main drawing functions
|
-- main drawing functions
|
||||||
|
|
||||||
local rbs = common.reduce_blocks_(
|
local rbs = compile.compile_module(
|
||||||
|
common,
|
||||||
'NVIDIA GRAPHICS',
|
'NVIDIA GRAPHICS',
|
||||||
point,
|
point,
|
||||||
width,
|
width,
|
||||||
{{mk_status, true, SEPARATOR_SPACING}},
|
{{mk_status, true, SEPARATOR_SPACING}},
|
||||||
common.mk_section(
|
compile.mk_section(
|
||||||
SEPARATOR_SPACING,
|
SEPARATOR_SPACING,
|
||||||
mk_sep,
|
mk_sep,
|
||||||
{mk_temp, config.show_temp, SEPARATOR_SPACING}
|
{mk_temp, config.show_temp, SEPARATOR_SPACING}
|
||||||
),
|
),
|
||||||
common.mk_section(
|
compile.mk_section(
|
||||||
SEPARATOR_SPACING,
|
SEPARATOR_SPACING,
|
||||||
mk_sep,
|
mk_sep,
|
||||||
{mk_clock, config.show_clock, SEPARATOR_SPACING}
|
{mk_clock, config.show_clock, SEPARATOR_SPACING}
|
||||||
),
|
),
|
||||||
common.mk_section(
|
compile.mk_section(
|
||||||
SEPARATOR_SPACING,
|
SEPARATOR_SPACING,
|
||||||
mk_sep,
|
mk_sep,
|
||||||
{mk_gpu_util, config.show_gpu_util, PLOT_SEC_BREAK},
|
{mk_gpu_util, config.show_gpu_util, PLOT_SEC_BREAK},
|
||||||
|
|
|
@ -1,10 +1,10 @@
|
||||||
local timeseries = require 'timeseries'
|
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 pure = require 'pure'
|
local pure = require 'pure'
|
||||||
|
local compile = require 'compile'
|
||||||
|
|
||||||
return function(update_freq, config, width, point)
|
return function(update_freq, config, common, width, point)
|
||||||
local DIAL_THICKNESS = 8
|
local DIAL_THICKNESS = 8
|
||||||
local DIAL_RADIUS = 32
|
local DIAL_RADIUS = 32
|
||||||
local DIAL_SPACING = 40
|
local DIAL_SPACING = 40
|
||||||
|
@ -78,7 +78,7 @@ return function(update_freq, config, width, 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(width, DIAL_DIAMETER, update, static, dynamic)
|
return compile.mk_acc(width, DIAL_DIAMETER, update, static, dynamic)
|
||||||
end
|
end
|
||||||
|
|
||||||
-----------------------------------------------------------------------------
|
-----------------------------------------------------------------------------
|
||||||
|
@ -92,7 +92,7 @@ return function(update_freq, config, width, point)
|
||||||
PLOT_HEIGHT,
|
PLOT_HEIGHT,
|
||||||
update_freq
|
update_freq
|
||||||
)
|
)
|
||||||
return common.mk_acc(
|
return compile.mk_acc(
|
||||||
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,
|
||||||
|
@ -130,7 +130,7 @@ return function(update_freq, config, width, point)
|
||||||
text_table.set(obj, 3, r, i_o.conky(TABLE_CONKY[r].mem))
|
text_table.set(obj, 3, r, i_o.conky(TABLE_CONKY[r].mem))
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
return common.mk_acc(
|
return compile.mk_acc(
|
||||||
width,
|
width,
|
||||||
TABLE_HEIGHT,
|
TABLE_HEIGHT,
|
||||||
update,
|
update,
|
||||||
|
@ -179,7 +179,8 @@ return function(update_freq, config, width, point)
|
||||||
-----------------------------------------------------------------------------
|
-----------------------------------------------------------------------------
|
||||||
-- main functions
|
-- main functions
|
||||||
|
|
||||||
local rbs = common.reduce_blocks_(
|
local rbs = compile.compile_module(
|
||||||
|
common,
|
||||||
'MEMORY',
|
'MEMORY',
|
||||||
point,
|
point,
|
||||||
width,
|
width,
|
||||||
|
|
|
@ -1,10 +1,10 @@
|
||||||
local format = require 'format'
|
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 sys = require 'sys'
|
local sys = require 'sys'
|
||||||
|
local compile = require 'compile'
|
||||||
|
|
||||||
return function(update_freq, width, point)
|
return function(update_freq, common, 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()
|
||||||
|
@ -51,7 +51,7 @@ return function(update_freq, width, point)
|
||||||
update_freq,
|
update_freq,
|
||||||
state[key]
|
state[key]
|
||||||
)
|
)
|
||||||
return common.mk_acc(
|
return compile.mk_acc(
|
||||||
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,
|
||||||
|
@ -66,7 +66,8 @@ return function(update_freq, width, point)
|
||||||
-----------------------------------------------------------------------------
|
-----------------------------------------------------------------------------
|
||||||
-- main drawing functions
|
-- main drawing functions
|
||||||
|
|
||||||
local rbs = common.reduce_blocks_(
|
local rbs = compile.compile_module(
|
||||||
|
common,
|
||||||
'NETWORK',
|
'NETWORK',
|
||||||
point,
|
point,
|
||||||
width,
|
width,
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
local common = require 'common'
|
local compile = require 'compile'
|
||||||
local pure = require 'pure'
|
local pure = require 'pure'
|
||||||
|
|
||||||
return function(main_state, width, point)
|
return function(main_state, common, width, point)
|
||||||
local TEXT_SPACING = 20
|
local TEXT_SPACING = 20
|
||||||
|
|
||||||
local __string_match = string.match
|
local __string_match = string.match
|
||||||
|
@ -32,7 +32,7 @@ return function(main_state, width, point)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
return common.mk_acc(
|
return compile.mk_acc(
|
||||||
width,
|
width,
|
||||||
TEXT_SPACING * 4,
|
TEXT_SPACING * 4,
|
||||||
update,
|
update,
|
||||||
|
@ -41,7 +41,8 @@ return function(main_state, width, point)
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
|
|
||||||
return common.reduce_blocks_(
|
return compile.compile_module(
|
||||||
|
common,
|
||||||
'PACMAN',
|
'PACMAN',
|
||||||
point,
|
point,
|
||||||
width,
|
width,
|
||||||
|
|
|
@ -1,9 +1,9 @@
|
||||||
local format = require 'format'
|
local format = require 'format'
|
||||||
local pure = require 'pure'
|
local pure = require 'pure'
|
||||||
local common = require 'common'
|
local compile = require 'compile'
|
||||||
local sys = require 'sys'
|
local sys = require 'sys'
|
||||||
|
|
||||||
return function(update_freq, config, width, point)
|
return function(update_freq, config, common, 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
|
||||||
|
@ -40,7 +40,7 @@ return function(update_freq, config, width, point)
|
||||||
update_freq,
|
update_freq,
|
||||||
read_joules()
|
read_joules()
|
||||||
)
|
)
|
||||||
return common.mk_acc(
|
return compile.mk_acc(
|
||||||
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,
|
||||||
|
@ -89,7 +89,7 @@ return function(update_freq, config, width, point)
|
||||||
0,
|
0,
|
||||||
update_freq
|
update_freq
|
||||||
)
|
)
|
||||||
return common.mk_acc(
|
return compile.mk_acc(
|
||||||
width,
|
width,
|
||||||
PLOT_HEIGHT + PLOT_SEC_BREAK,
|
PLOT_HEIGHT + PLOT_SEC_BREAK,
|
||||||
function()
|
function()
|
||||||
|
@ -106,7 +106,8 @@ return function(update_freq, config, width, point)
|
||||||
-----------------------------------------------------------------------------
|
-----------------------------------------------------------------------------
|
||||||
-- main functions
|
-- main functions
|
||||||
|
|
||||||
return common.reduce_blocks_(
|
return compile.compile_module(
|
||||||
|
common,
|
||||||
'POWER',
|
'POWER',
|
||||||
point,
|
point,
|
||||||
width,
|
width,
|
||||||
|
|
|
@ -1,13 +1,13 @@
|
||||||
local compound_dial = require 'compound_dial'
|
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 compile = require 'compile'
|
||||||
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, width, point)
|
return function(update_freq, config, main_state, common, 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
|
||||||
|
@ -91,7 +91,7 @@ return function(update_freq, config, main_state, width, point)
|
||||||
compound_dial.draw_dynamic(cores[i].loads, cr)
|
compound_dial.draw_dynamic(cores[i].loads, cr)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
return common.mk_acc(
|
return compile.mk_acc(
|
||||||
width,
|
width,
|
||||||
DIAL_OUTER_RADIUS * 2,
|
DIAL_OUTER_RADIUS * 2,
|
||||||
update,
|
update,
|
||||||
|
@ -123,7 +123,7 @@ return function(update_freq, config, main_state, width, point)
|
||||||
end
|
end
|
||||||
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 compile.mk_acc(
|
||||||
width,
|
width,
|
||||||
TEXT_SPACING,
|
TEXT_SPACING,
|
||||||
update,
|
update,
|
||||||
|
@ -136,7 +136,8 @@ return function(update_freq, config, main_state, width, point)
|
||||||
-- frequency
|
-- frequency
|
||||||
|
|
||||||
local mk_sep = pure.partial(
|
local mk_sep = pure.partial(
|
||||||
common.mk_seperator,
|
compile.mk_seperator,
|
||||||
|
common,
|
||||||
width,
|
width,
|
||||||
point.x
|
point.x
|
||||||
)
|
)
|
||||||
|
@ -163,7 +164,7 @@ return function(update_freq, config, main_state, width, point)
|
||||||
end
|
end
|
||||||
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 compile.mk_acc(
|
||||||
width,
|
width,
|
||||||
PLOT_HEIGHT + PLOT_SECTION_BREAK,
|
PLOT_HEIGHT + PLOT_SECTION_BREAK,
|
||||||
update,
|
update,
|
||||||
|
@ -202,7 +203,7 @@ return function(update_freq, config, main_state, width, point)
|
||||||
end
|
end
|
||||||
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 compile.mk_acc(
|
||||||
width,
|
width,
|
||||||
TABLE_HEIGHT,
|
TABLE_HEIGHT,
|
||||||
update,
|
update,
|
||||||
|
@ -214,7 +215,8 @@ return function(update_freq, config, main_state, width, point)
|
||||||
-----------------------------------------------------------------------------
|
-----------------------------------------------------------------------------
|
||||||
-- main functions
|
-- main functions
|
||||||
|
|
||||||
local rbs = common.reduce_blocks_(
|
local rbs = compile.compile_module(
|
||||||
|
common,
|
||||||
'PROCESSOR',
|
'PROCESSOR',
|
||||||
point,
|
point,
|
||||||
width,
|
width,
|
||||||
|
@ -222,7 +224,7 @@ return function(update_freq, config, main_state, width, point)
|
||||||
{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},
|
||||||
},
|
},
|
||||||
common.mk_section(
|
compile.mk_section(
|
||||||
SEPARATOR_SPACING,
|
SEPARATOR_SPACING,
|
||||||
mk_sep,
|
mk_sep,
|
||||||
{mk_load_plot, config.show_plot, TABLE_SECTION_BREAK},
|
{mk_load_plot, config.show_plot, TABLE_SECTION_BREAK},
|
||||||
|
|
|
@ -1,9 +1,9 @@
|
||||||
local format = require 'format'
|
local format = require 'format'
|
||||||
local pure = require 'pure'
|
local pure = require 'pure'
|
||||||
local common = require 'common'
|
local compile = require 'compile'
|
||||||
local sys = require 'sys'
|
local sys = require 'sys'
|
||||||
|
|
||||||
return function(update_freq, config, width, point)
|
return function(update_freq, config, common, 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
|
||||||
|
@ -34,7 +34,7 @@ return function(update_freq, config, width, point)
|
||||||
update_freq,
|
update_freq,
|
||||||
state[key]
|
state[key]
|
||||||
)
|
)
|
||||||
return common.mk_acc(
|
return compile.mk_acc(
|
||||||
-- TODO construct this more sanely without referring to hardcoded vars
|
-- TODO construct this more sanely without referring to hardcoded vars
|
||||||
width,
|
width,
|
||||||
PLOT_HEIGHT + PLOT_SEC_BREAK,
|
PLOT_HEIGHT + PLOT_SEC_BREAK,
|
||||||
|
@ -50,7 +50,8 @@ return function(update_freq, config, width, point)
|
||||||
-----------------------------------------------------------------------------
|
-----------------------------------------------------------------------------
|
||||||
-- main drawing functions
|
-- main drawing functions
|
||||||
|
|
||||||
local rbs = common.reduce_blocks_(
|
local rbs = compile.compile_module(
|
||||||
|
common,
|
||||||
'INPUT / OUTPUT',
|
'INPUT / OUTPUT',
|
||||||
point,
|
point,
|
||||||
width,
|
width,
|
||||||
|
|
|
@ -1,121 +0,0 @@
|
||||||
local common = require 'common'
|
|
||||||
local pure = require 'pure'
|
|
||||||
local geom = require 'geom'
|
|
||||||
local fill_rect = require 'fill_rect'
|
|
||||||
|
|
||||||
local reduce_modules_y = function(modlist, init_x, width, acc, new)
|
|
||||||
if type(new) == "number" then
|
|
||||||
acc.next_y = acc.next_y + new
|
|
||||||
else
|
|
||||||
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})
|
|
||||||
acc.next_x = math.max(acc.next_x, r.next_x)
|
|
||||||
acc.next_y = r.next_y
|
|
||||||
end
|
|
||||||
return acc
|
|
||||||
end
|
|
||||||
|
|
||||||
local reduce_modules_x = function(modlist, init_y, acc, x_mods)
|
|
||||||
if type(x_mods) == "number" then
|
|
||||||
acc.next_x = acc.next_x + x_mods
|
|
||||||
else
|
|
||||||
local r = pure.reduce(
|
|
||||||
pure.partial(reduce_modules_y, modlist, acc.next_x, x_mods.width),
|
|
||||||
{next_x = acc.next_x, next_y = init_y, fgroups = acc.fgroups},
|
|
||||||
x_mods.blocks
|
|
||||||
)
|
|
||||||
acc.fgroups = r.fgroups
|
|
||||||
acc.next_x = r.next_x
|
|
||||||
acc.next_y = math.max(acc.next_y, r.next_y)
|
|
||||||
end
|
|
||||||
return acc
|
|
||||||
end
|
|
||||||
|
|
||||||
local arrange_panel_modules = function(modlist, point, mods)
|
|
||||||
local r = pure.reduce(
|
|
||||||
pure.partial(reduce_modules_x, modlist, point.y),
|
|
||||||
{next_x = point.x, next_y = point.y, fgroups = {}},
|
|
||||||
mods
|
|
||||||
)
|
|
||||||
return {
|
|
||||||
point_ul = point,
|
|
||||||
width = r.next_x - point.x,
|
|
||||||
height = r.next_y - point.y,
|
|
||||||
update = pure.map_keys('update', r.fgroups),
|
|
||||||
static = pure.map_keys('static', r.fgroups),
|
|
||||||
dynamic = pure.map_keys('dynamic', r.fgroups),
|
|
||||||
}
|
|
||||||
end
|
|
||||||
|
|
||||||
local build_surface = function(box, fs)
|
|
||||||
local panel_line_thickness = 1
|
|
||||||
-- move over by half a pixel so the lines don't need to be antialiased
|
|
||||||
local _x = box.corner.x + 0.5
|
|
||||||
local _y = box.corner.y + 0.5
|
|
||||||
local panel = common.make_panel(_x, _y, box.width, box.height, panel_line_thickness)
|
|
||||||
local cs_x = _x - panel_line_thickness * 0.5
|
|
||||||
local cs_y = _y - panel_line_thickness * 0.5
|
|
||||||
local cs_w = box.width + panel_line_thickness
|
|
||||||
local cs_h = box.height + panel_line_thickness
|
|
||||||
|
|
||||||
local cs = cairo_image_surface_create(CAIRO_FORMAT_ARGB32, cs_w, cs_h)
|
|
||||||
local cr = cairo_create(cs)
|
|
||||||
|
|
||||||
cairo_translate(cr, -cs_x, -cs_y)
|
|
||||||
|
|
||||||
fill_rect.draw(panel, cr)
|
|
||||||
for i = 1, #fs do
|
|
||||||
fs[i](cr)
|
|
||||||
end
|
|
||||||
cairo_destroy(cr)
|
|
||||||
return {x = cs_x, y = cs_y, s = cs}
|
|
||||||
end
|
|
||||||
|
|
||||||
local reduce_static = function(mods, y, acc, panel_mods)
|
|
||||||
if type(panel_mods) == "number" then
|
|
||||||
acc.next_x = acc.next_x + panel_mods
|
|
||||||
else
|
|
||||||
local margins = panel_mods.margins
|
|
||||||
local margin_x = margins[1]
|
|
||||||
local margin_y = margins[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)
|
|
||||||
acc.next_x = acc.next_x + w
|
|
||||||
acc.static = pure.flatten({acc.static, {build_surface(pbox, r.static)}})
|
|
||||||
acc.update = pure.flatten({acc.update, r.update})
|
|
||||||
acc.dynamic = pure.flatten({acc.dynamic, r.dynamic})
|
|
||||||
end
|
|
||||||
return acc
|
|
||||||
end
|
|
||||||
|
|
||||||
return function(point, mods, module_sets)
|
|
||||||
local __cairo_set_source_surface = cairo_set_source_surface
|
|
||||||
local __cairo_paint = cairo_paint
|
|
||||||
|
|
||||||
local r = pure.reduce(
|
|
||||||
pure.partial(
|
|
||||||
reduce_static,
|
|
||||||
mods,
|
|
||||||
point.y
|
|
||||||
),
|
|
||||||
{next_x = point.x, static = {}, update = {}, dynamic = {}},
|
|
||||||
module_sets
|
|
||||||
)
|
|
||||||
|
|
||||||
local cs = r.static
|
|
||||||
|
|
||||||
return {
|
|
||||||
static = function(cr)
|
|
||||||
for i = 1, #cs do
|
|
||||||
local c = cs[i]
|
|
||||||
__cairo_set_source_surface(cr, c.s, c.x, c.y)
|
|
||||||
__cairo_paint(cr)
|
|
||||||
end
|
|
||||||
end,
|
|
||||||
update = pure.sequence(table.unpack(r.update)),
|
|
||||||
dynamic = pure.sequence(table.unpack(r.dynamic)),
|
|
||||||
}
|
|
||||||
end
|
|
|
@ -1,8 +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 compile = require 'compile'
|
||||||
|
|
||||||
return function(main_state, width, point)
|
return function(main_state, common, width, point)
|
||||||
local TEXT_SPACING = 20
|
local TEXT_SPACING = 20
|
||||||
|
|
||||||
local __string_match = string.match
|
local __string_match = string.match
|
||||||
|
@ -23,7 +23,7 @@ return function(main_state, width, point)
|
||||||
"^%d+%s+([^%s]+)%s+([^%s]+).*"
|
"^%d+%s+([^%s]+)%s+([^%s]+).*"
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
-- TODO this doesn't need to be update every time
|
-- TODO this doesn't need to be updated every time
|
||||||
common.text_rows_set(obj, 1, i_o.conky('$kernel'))
|
common.text_rows_set(obj, 1, i_o.conky('$kernel'))
|
||||||
common.text_rows_set(obj, 2, i_o.conky('$uptime'))
|
common.text_rows_set(obj, 2, i_o.conky('$uptime'))
|
||||||
common.text_rows_set(obj, 3, last_update)
|
common.text_rows_set(obj, 3, last_update)
|
||||||
|
@ -31,7 +31,7 @@ return function(main_state, width, 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(
|
return compile.mk_acc(
|
||||||
width,
|
width,
|
||||||
TEXT_SPACING * 3,
|
TEXT_SPACING * 3,
|
||||||
update,
|
update,
|
||||||
|
@ -40,10 +40,5 @@ return function(main_state, width, point)
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
|
|
||||||
return common.reduce_blocks_(
|
return compile.compile_module(common, 'SYSTEM', point, width, {{mk_stats, true, 0}})
|
||||||
'SYSTEM',
|
|
||||||
point,
|
|
||||||
width,
|
|
||||||
{{mk_stats, true, 0}}
|
|
||||||
)
|
|
||||||
end
|
end
|
||||||
|
|
23
main.lua
23
main.lua
|
@ -32,21 +32,19 @@ 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 compile = require 'compile'
|
||||||
|
local common = require 'common'
|
||||||
local yaml = require 'lyaml'
|
local yaml = require 'lyaml'
|
||||||
|
|
||||||
local draw_dynamic
|
local draw_dynamic
|
||||||
|
|
||||||
function conky_start(update_interval)
|
local build_main = function(update_interval, config_path)
|
||||||
conky_set_update_interval(update_interval)
|
|
||||||
|
|
||||||
local update_freq = 1 / update_interval
|
local update_freq = 1 / update_interval
|
||||||
|
local config = yaml.load(i_o.read_file(config_path))
|
||||||
|
local cmods = config.modules
|
||||||
|
|
||||||
local main_state = {}
|
local main_state = {}
|
||||||
|
|
||||||
local config = yaml.load(i_o.read_file(ABS_PATH..'config.yml'))
|
|
||||||
local cmods = config.modules
|
|
||||||
|
|
||||||
local mods = {
|
local mods = {
|
||||||
memory = pure.partial(memory, update_freq, cmods.memory),
|
memory = pure.partial(memory, update_freq, cmods.memory),
|
||||||
readwrite = pure.partial(readwrite, update_freq, cmods.readwrite),
|
readwrite = pure.partial(readwrite, update_freq, cmods.readwrite),
|
||||||
|
@ -59,7 +57,8 @@ function conky_start(update_interval)
|
||||||
pacman = pure.partial(pacman, main_state)
|
pacman = pure.partial(pacman, main_state)
|
||||||
}
|
}
|
||||||
|
|
||||||
local compiled = static(
|
local compiled = compile.compile_layout(
|
||||||
|
common(config),
|
||||||
geom.make_point(table.unpack(config.layout.anchor)),
|
geom.make_point(table.unpack(config.layout.anchor)),
|
||||||
mods,
|
mods,
|
||||||
config.layout.panels
|
config.layout.panels
|
||||||
|
@ -67,7 +66,7 @@ function conky_start(update_interval)
|
||||||
|
|
||||||
local STATS_FILE = '/tmp/.conky_pacman'
|
local STATS_FILE = '/tmp/.conky_pacman'
|
||||||
|
|
||||||
draw_dynamic = function(cr, _updates)
|
return function(cr, _updates)
|
||||||
main_state.trigger10 = _updates % (update_freq * 10)
|
main_state.trigger10 = _updates % (update_freq * 10)
|
||||||
main_state.pacman_stats = i_o.read_file(STATS_FILE)
|
main_state.pacman_stats = i_o.read_file(STATS_FILE)
|
||||||
|
|
||||||
|
@ -77,6 +76,12 @@ function conky_start(update_interval)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
function conky_start(update_interval)
|
||||||
|
conky_set_update_interval(update_interval)
|
||||||
|
|
||||||
|
draw_dynamic = build_main(update_interval, ABS_PATH..'config.yml')
|
||||||
|
end
|
||||||
|
|
||||||
local updates = -2 -- this accounts for the first few spazzy iterations
|
local updates = -2 -- this accounts for the first few spazzy iterations
|
||||||
|
|
||||||
function conky_main()
|
function conky_main()
|
||||||
|
|
Loading…
Reference in New Issue