Merge branch 'use_dhall'

This commit is contained in:
Nathan Dwarshuis 2022-08-28 23:44:47 -04:00
commit e517b31ea5
15 changed files with 586 additions and 201 deletions

323
config/config.dhall Normal file
View File

@ -0,0 +1,323 @@
let Vector2 = \(a : Type) -> { x : a, y : a }
let Point = Vector2 Natural
let Margin = Vector2 Natural
let FSPath = { name : Text, path : Text }
let TextGeo = { Type = { text_spacing : Natural }, default.text_spacing = 20 }
let SepGeo = { Type = { sep_spacing : Natural }, default.sep_spacing = 20 }
let PlotGeo_ =
{ Type = { sec_break : Natural, height : Natural, ticks_y : Natural }
, default = { sec_break = 20, height = 56, ticks_y = 4 }
}
let PlotGeo = { Type = { plot : PlotGeo_.Type }, default.plot = PlotGeo_::{=} }
let TableGeo_ = { Type = { sec_break : Natural }, default.sec_break = 20 }
let TableGeo =
{ Type = { table : TableGeo_.Type }, default.table = TableGeo_::{=} }
let FSGeo =
{ Type = { bar_spacing : Natural, bar_pad : Natural } //\\ SepGeo.Type
, default = { bar_spacing = 20, bar_pad = 100 } /\ SepGeo::{=}
}
let GfxGeo =
{ Type = SepGeo.Type //\\ PlotGeo.Type //\\ TextGeo.Type
, default = SepGeo::{=} /\ PlotGeo::{=} /\ TextGeo::{=}
}
let MemGeo =
{ Type = TextGeo.Type //\\ PlotGeo.Type //\\ TableGeo.Type
, default = TextGeo::{=} /\ PlotGeo::{=} /\ TableGeo::{=}
}
let ProcGeo =
{ Type = GfxGeo.Type //\\ TableGeo.Type
, default = GfxGeo::{=} /\ TableGeo::{=}
}
let PwrGeo =
{ Type = TextGeo.Type //\\ PlotGeo.Type
, default = TextGeo::{=} /\ PlotGeo::{=}
}
let FileSystem =
{ Type =
{ show_smart : Bool, fs_paths : List FSPath, geometry : FSGeo.Type }
, default.geometry = FSGeo::{=}
}
let Graphics =
{ Type =
{ dev_power : Text
, show_temp : Bool
, show_clock : Bool
, show_gpu_util : Bool
, show_mem_util : Bool
, show_vid_util : Bool
, geometry : GfxGeo.Type
}
, default.geometry = GfxGeo::{=}
}
let Memory =
{ Type =
{ show_stats : Bool
, show_plot : Bool
, show_swap : Bool
, table_rows : Natural
, geometry : MemGeo.Type
}
, default.geometry = MemGeo::{=}
}
let Network =
{ Type = { geometry : PlotGeo.Type }, default.geometry = PlotGeo::{=} }
let Processor =
{ Type =
{ core_rows : Natural
, core_padding : Natural
, show_stats : Bool
, show_plot : Bool
, table_rows : Natural
, geometry : ProcGeo.Type
}
, default.geometry = ProcGeo::{=}
}
let RaplSpec = { name : Text, address : Text }
let Pacman =
{ Type = { geometry : TextGeo.Type }, default.geometry = TextGeo::{=} }
let Power =
{ Type =
{ battery : Text, rapl_specs : List RaplSpec, geometry : PwrGeo.Type }
, default.geometry = PwrGeo::{=}
}
let ReadWrite =
{ Type = { devices : List Text, geometry : PlotGeo.Type }
, default.geometry = PlotGeo::{=}
}
let System = Pacman
let ModType =
< filesystem : FileSystem.Type
| graphics : Graphics.Type
| memory : Memory.Type
| network : Network.Type
| pacman : Pacman.Type
| processor : Processor.Type
| power : Power.Type
| readwrite : ReadWrite.Type
| system : System.Type
>
let Annotated = \(a : Type) -> { type : Text, data : a }
let Block = < Pad : Natural | Mod : Annotated ModType >
let Column_ = { blocks : List Block, width : Natural }
let Column = < CPad : Natural | CCol : Column_ >
let Panel_ = { columns : List Column, margins : Margin }
let Panel = < PPad : Natural | PPanel : Panel_ >
let Layout = { anchor : Point, panels : List Panel }
let Sizes =
{ Type =
{ normal : Natural
, plot_label : Natural
, table : Natural
, header : Natural
}
, default = { normal = 13, plot_label = 8, table = 11, header = 15 }
}
let Font =
{ Type = { family : Text, sizes : Sizes.Type }
, default = { family = "Neuropolitical", sizes = Sizes::{=} }
}
let PlotGeometry =
{ Type = { seconds : Natural, ticks_x : Natural }
, default = { seconds = 90, ticks_x = 9 }
}
let TableGeometry =
{ Type =
{ name_chars : Natural
, padding : Margin
, header_padding : Natural
, row_spacing : Natural
}
, default =
{ name_chars = 8
, padding = { x = 6, y = 15 }
, header_padding = 20
, row_spacing = 16
}
}
let HeaderGeometry =
{ Type = { underline_offset : Natural, padding : Natural }
, default = { underline_offset = 26, padding = 19 }
}
let Geometry =
{ Type =
{ plot : PlotGeometry.Type
, table : TableGeometry.Type
, header : HeaderGeometry.Type
}
, default =
{ plot = PlotGeometry::{=}
, table = TableGeometry::{=}
, header = HeaderGeometry::{=}
}
}
let StopRGB = { color : Natural, stop : Double }
let StopRGBA = { color : Natural, stop : Double, alpha : Double }
let ColorAlpha = { color : Natural, alpha : Double }
let Pattern =
< RGB : Natural
| RGBA : ColorAlpha
| GradientRGB : List StopRGB
| GradientRGBA : List StopRGBA
>
let annotatePattern =
\(a : Pattern) ->
{ type = showConstructor a, data = a } : Annotated Pattern
let mod = \(a : ModType) -> Block.Mod { type = showConstructor a, data = a }
let APattern = Annotated Pattern
let symGradient =
\(c0 : Natural) ->
\(c1 : Natural) ->
annotatePattern
( Pattern.GradientRGB
[ { color = c0, stop = 0.0 }
, { color = c1, stop = 0.5 }
, { color = c0, stop = 1.0 }
]
)
let Patterns =
{ Type =
{ header : APattern
, panel : { bg : APattern }
, text :
{ active : APattern, inactive : APattern, critical : APattern }
, border : APattern
, plot :
{ grid : APattern
, outline : APattern
, data : { border : APattern, fill : APattern }
}
, indicator :
{ bg : APattern, fg : { active : APattern, critical : APattern } }
}
, default =
{ header = annotatePattern (Pattern.RGB 0xefefef)
, panel.bg
= annotatePattern (Pattern.RGBA { color = 0x121212, alpha = 0.7 })
, text =
{ active = annotatePattern (Pattern.RGB 0xbfe1ff)
, inactive = annotatePattern (Pattern.RGB 0xc8c8c8)
, critical = annotatePattern (Pattern.RGB 0xff8282)
}
, border = annotatePattern (Pattern.RGB 0x888888)
, plot =
{ grid = annotatePattern (Pattern.RGB 0x666666)
, outline = annotatePattern (Pattern.RGB 0x777777)
, data =
{ border =
annotatePattern
( Pattern.GradientRGB
[ { color = 0x003f7c, stop = 0.0 }
, { color = 0x1e90ff, stop = 1.0 }
]
)
, fill =
annotatePattern
( Pattern.GradientRGBA
[ { color = 0x316ece, stop = 0.2, alpha = 0.5 }
, { color = 0x8cc7ff, stop = 1.0, alpha = 1.0 }
]
)
}
}
, indicator =
{ bg = symGradient 0x565656 0xbfbfbf
, fg =
{ active = symGradient 0x316BA6 0x99CEFF
, critical = symGradient 0xFF3333 0xFFB8B8
}
}
}
}
let Theme =
{ Type =
{ font : Font.Type
, geometry : Geometry.Type
, patterns : Patterns.Type
}
, default =
{ font = Font::{=}, geometry = Geometry::{=}, patterns = Patterns::{=} }
}
let Bootstrap = { update_interval : Natural, dimensions : Point }
let Config = { bootstrap : Bootstrap, theme : Theme.Type, layout : Layout }
let toConfig =
\(i : Natural) ->
\(x : Natural) ->
\(y : Natural) ->
\(t : Theme.Type) ->
\(l : Layout) ->
{ bootstrap = { update_interval = i, dimensions = { x, y } }
, theme = t
, layout = l
}
: Config
in { toConfig
, Block
, Column
, ModType
, Layout
, Panel
, FSPath
, FileSystem
, Graphics
, Memory
, Network
, Pacman
, Processor
, Power
, ReadWrite
, System
, Theme
, mod
}

43
config/fallback.dhall Normal file
View File

@ -0,0 +1,43 @@
let C = ./config.dhall
let memory =
C.ModType.memory
C.Memory::{
, show_stats = False
, show_swap = False
, show_plot = True
, table_rows = 3
}
let processor =
C.ModType.processor
C.Processor::{
, core_rows = 0
, core_padding = 0
, show_stats = False
, show_plot = True
, table_rows = 3
}
let layout =
{ anchor = { x = 12, y = 11 }
, panels =
[ C.Panel.PPanel
{ columns =
[ C.Column.CCol
{ blocks =
[ C.mod (C.ModType.network C.Network::{=})
, C.Block.Pad 10
, C.mod memory
, C.Block.Pad 10
, C.mod processor
]
, width = 436
}
]
, margins = { x = 20, y = 10 }
}
]
}
in C.toConfig 1 1920 1080 C.Theme::{=} layout

View File

@ -55,37 +55,25 @@ package.cpath = conky_dir..'lib/lib/lua/5.4/?.so;'
local yaml = require 'lyaml' local yaml = require 'lyaml'
local i_o = require 'i_o' local i_o = require 'i_o'
local schema_path = conky_dir..'/config/schema.yml' local config_path = '/tmp/conky.yml'
local validate_config
if i_o.exe_exists('yajsv') then local try_read_config = function(path)
validate_config = function(config_path) local cmd = string.format('dhall-to-yaml --file %s > %s', path, config_path)
local cmd = string.format('yajsv -q -s %s %s', schema_path, config_path) return i_o.exit_code_cmd(cmd)
return i_o.exit_code_cmd(cmd) == 0
end
else
validate_config = function(_)
i_o.warnf('could not validate config')
return true
end
end end
local find_valid_config = function(paths) local find_valid_config = function(paths)
for i = 1, #paths do for i = 1, #paths do
local path = paths[i] local path = paths[i]
local r = i_o.read_file(path) local rc = try_read_config(path)
if r ~= nil then if rc == 0 then
if validate_config(path) then i_o.infof('Using config at %s', path)
i_o.infof('Using config at %s', path) return yaml.load(i_o.read_file(config_path))
return path, yaml.load(r)
else
i_o.warnf('%s did not pass; trying next', path)
end
else else
i_o.infof('could not find %s; trying next', path) i_o.warnf('could not read %s; trying next', path)
end end
end end
i_o.assertf(false, 'ERROR: could not load valid config') i_o.assertf(false, 'could not load valid config')
end end
local get_config_dir = function() local get_config_dir = function()
@ -93,11 +81,11 @@ local get_config_dir = function()
end end
local try_config_paths = { local try_config_paths = {
get_config_dir()..'conky.yml', get_config_dir()..'conky.dhall',
conky_dir..'config/fallback.yml' conky_dir..'config/fallback.dhall'
} }
local config_path, config = find_valid_config(try_config_paths) local config = find_valid_config(try_config_paths)
local bootstrap = config.bootstrap local bootstrap = config.bootstrap
@ -125,8 +113,8 @@ conky.config = {
xinerama_head = 0, xinerama_head = 0,
double_buffer = true, double_buffer = true,
minimum_width = bootstrap.dimensions[1], minimum_width = bootstrap.dimensions.x,
minimum_height = bootstrap.dimensions[2], minimum_height = bootstrap.dimensions.y,
draw_shades = false, draw_shades = false,
draw_outline = false, draw_outline = false,

View File

@ -61,14 +61,14 @@ local compile_patterns
compile_patterns = function(patterns) compile_patterns = function(patterns)
local r = {} local r = {}
for k, v in pairs(patterns) do for k, v in pairs(patterns) do
if type(v) == "number" then if v.type == "RGB" then
r[k] = rgb(v) r[k] = rgb(v.data)
elseif v.color ~= nil then elseif v.type == "RGBA" then
r[k] = rgba(v.color, v.alpha) r[k] = rgba(v.data.color, v.data.alpha)
elseif v.gradient ~= nil then elseif v.type == "GradientRGB" then
r[k] = compile_gradient(v.gradient) r[k] = compile_gradient(v.data)
elseif v.gradient_alpha ~= nil then elseif v.type == "GradientRGBA" then
r[k] = compile_gradient_alpha(v.gradient_alpha) r[k] = compile_gradient_alpha(v.data)
else else
r[k] = compile_patterns(v) r[k] = compile_patterns(v)
end end

View File

@ -18,7 +18,8 @@ local reduce_modules_y = function(common_, 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 m = modlist[new](common_, width, geom.make_point(init_x, acc.next_y)) local m = modlist[new.type](new.data, common_, width, geom.make_point(init_x, acc.next_y))
-- local m = modlist[new](common_, width, geom.make_point(init_x, acc.next_y))
local r = common_.compile_module( local r = common_.compile_module(
m.header, m.header,
m.point, m.point,
@ -99,8 +100,8 @@ local reduce_static = function(common_, mods, y, acc, panel_mods)
acc.next_x = acc.next_x + panel_mods acc.next_x = acc.next_x + panel_mods
else else
local margins = panel_mods.margins local margins = panel_mods.margins
local margin_x = margins[1] local margin_x = margins.x
local margin_y = margins[2] local margin_y = margins.y
local mpoint = geom.make_point(acc.next_x + margin_x, y + margin_y) 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 r = arrange_panel_modules(common_, mods, mpoint, panel_mods.columns)
local w = r.width + margin_x * 2 local w = r.width + margin_x * 2
@ -147,26 +148,27 @@ end
return function(update_interval, config_path) return function(update_interval, config_path)
local update_freq = 1 / update_interval local update_freq = 1 / update_interval
local config = yaml.load(i_o.read_file(config_path)) local config = yaml.load(i_o.read_file(config_path))
local cmods = config.modules
local main_state = {} local main_state = {}
local mods = { local modlist = {
memory = pure.partial(memory, update_freq, cmods.memory), memory = pure.partial(memory, update_freq),
readwrite = pure.partial(readwrite, update_freq, cmods.readwrite), readwrite = pure.partial(readwrite, update_freq),
network = pure.partial(network, update_freq), network = pure.partial(network, update_freq),
power = pure.partial(power, update_freq, cmods.power), power = pure.partial(power, update_freq),
filesystem = pure.partial(filesystem, cmods.filesystem, main_state), filesystem = pure.partial(filesystem, main_state),
system = pure.partial(system, main_state), system = pure.partial(system, main_state),
graphics = pure.partial(graphics, update_freq, cmods.graphics), graphics = pure.partial(graphics, update_freq),
processor = pure.partial(processor, update_freq, cmods.processor, main_state), processor = pure.partial(processor, update_freq, main_state),
pacman = pure.partial(pacman, main_state) pacman = pure.partial(pacman, main_state)
} }
local anchor = config.layout.anchor
local compiled = compile_layout( local compiled = compile_layout(
common(config), common(config),
geom.make_point(table.unpack(config.layout.anchor)), geom.make_point(anchor.x, anchor.y),
mods, modlist,
config.layout.panels config.layout.panels
) )

View File

@ -103,19 +103,23 @@ return function(config)
----------------------------------------------------------------------------- -----------------------------------------------------------------------------
-- timeseries helper functions -- timeseries helper functions
local _default_grid_config = timeseries.grid_config( local _default_grid_config = function(ticks_y)
geometry.plot.ticks[1], return timeseries.grid_config(
geometry.plot.ticks[2], geometry.plot.ticks_x,
patterns.plot.grid ticks_y,
) patterns.plot.grid
)
end
local _default_plot_config = timeseries.config( local _default_plot_config = function(ticks_y)
geometry.plot.seconds, return timeseries.config(
patterns.plot.outline, geometry.plot.seconds,
patterns.plot.data.border, patterns.plot.outline,
patterns.plot.data.fill, patterns.plot.data.border,
_default_grid_config patterns.plot.data.fill,
) _default_grid_config(ticks_y)
)
end
local _format_percent_label = function(_) local _format_percent_label = function(_)
return function(z) return __string_format('%i%%', math.floor(z * 100)) end return function(z) return __string_format('%i%%', math.floor(z * 100)) end
@ -131,18 +135,20 @@ return function(config)
_format_percent_label _format_percent_label
) )
local _make_timeseries = function(x, y, w, h, label_config, update_freq) local _make_timeseries = function(x, y, w, h, ticks_y, label_config, update_freq)
return timeseries.make( return timeseries.make(
geom.make_box(x, y, w, h), geom.make_box(x, y, w, h),
update_freq, update_freq,
_default_plot_config, _default_plot_config(ticks_y),
label_config label_config
) )
end end
local gplot = geometry.plot local gplot = geometry.plot
local _make_tagged_percent_timeseries = function(x, y, w, h, spacing, label, update_freq, _format) local _make_tagged_percent_timeseries = function(x, y, w, h, ticks_y,
spacing, label, update_freq,
_format)
return { return {
label = _left_text(geom.make_point(x, y), label), label = _left_text(geom.make_point(x, y), label),
value = text_threshold.make_formatted( value = text_threshold.make_formatted(
@ -157,6 +163,7 @@ return function(config)
y + _maybe_config(gplot.spacing, spacing), y + _maybe_config(gplot.spacing, spacing),
w, w,
_maybe_config(gplot.height, h), _maybe_config(gplot.height, h),
ticks_y,
update_freq update_freq
), ),
} }
@ -169,11 +176,11 @@ return function(config)
return scaled_timeseries.scaling_parameters(2, m, 0.9) return scaled_timeseries.scaling_parameters(2, m, 0.9)
end end
local _make_scaled_timeseries = function(x, y, w, h, f, min_domain, update_freq) local _make_scaled_timeseries = function(x, y, w, h, ticks_y, f, min_domain, update_freq)
return scaled_timeseries.make( return scaled_timeseries.make(
geom.make_box(x, y, w, h), geom.make_box(x, y, w, h),
update_freq, update_freq,
_default_plot_config, _default_plot_config(ticks_y),
timeseries.label_config(patterns.text.inactive, 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)
) )
@ -216,22 +223,24 @@ return function(config)
----------------------------------------------------------------------------- -----------------------------------------------------------------------------
-- percent timeseries -- percent timeseries
M.make_percent_timeseries = function(x, y, w, h, update_freq) M.make_percent_timeseries = function(x, y, w, h, ticks_y, update_freq)
return _make_timeseries(x, y, w, h, _percent_label_config, update_freq) return _make_timeseries(x, y, w, h, ticks_y, _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, ticks_y, spacing,
label, update_freq)
return _make_tagged_percent_timeseries( return _make_tagged_percent_timeseries(
x, y, w, h, spacing, label, update_freq, '%s%%' x, y, w, h, ticks_y, spacing, label, update_freq, '%s%%'
) )
end end
M.make_tagged_maybe_percent_timeseries = function(x, y, w, h, spacing, label, update_freq) M.make_tagged_maybe_percent_timeseries = function(x, y, w, h, ticks_y,
spacing, label, update_freq)
return _make_tagged_percent_timeseries( return _make_tagged_percent_timeseries(
x, y, w, h, spacing, label, update_freq, _format_percent_maybe x, y, w, h, ticks_y, spacing, label, update_freq, _format_percent_maybe
) )
end end
@ -294,9 +303,9 @@ return function(config)
----------------------------------------------------------------------------- -----------------------------------------------------------------------------
-- 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, ticks_y, format_fun,
spacing, label, min_domain, label_fun, spacing, label,
update_freq) min_domain, update_freq)
return { return {
label = _left_text(geom.make_point(x, y), label), label = _left_text(geom.make_point(x, y), label),
value = text.make_formatted( value = text.make_formatted(
@ -310,6 +319,7 @@ return function(config)
y + spacing, y + spacing,
w, w,
h, h,
ticks_y,
label_fun, label_fun,
min_domain, min_domain,
update_freq update_freq
@ -341,8 +351,9 @@ return function(config)
end end
end end
M.make_rate_timeseries = function(x, y, w, h, format_fun, label_fun, spacing, M.make_rate_timeseries = function(x, y, w, h, ticks_y, format_fun,
label, min_domain, update_freq, init) label_fun, spacing, label, min_domain,
update_freq, init)
return { return {
label = _left_text(geom.make_point(x, y), label), label = _left_text(geom.make_point(x, y), label),
value = text.make_formatted( value = text.make_formatted(
@ -356,6 +367,7 @@ return function(config)
y + spacing, y + spacing,
w, w,
h, h,
ticks_y,
label_fun, label_fun,
min_domain, min_domain,
update_freq update_freq
@ -615,8 +627,8 @@ return function(config)
local gtable = geometry.table local gtable = geometry.table
local padding = gtable.padding local padding = gtable.padding
local xpad = padding[1] local xpad = padding.x
local ypad = padding[2] local ypad = padding.y
local default_table_font_spec = make_font_spec(font_family, font_sizes.table, false) local default_table_font_spec = make_font_spec(font_family, font_sizes.table, false)

View File

@ -2,10 +2,10 @@ local i_o = require 'i_o'
local pure = require 'pure' local pure = require 'pure'
local impure = require 'impure' local impure = require 'impure'
return function(config, main_state, common, width, point) return function(main_state, config, common, width, point)
local SPACING = 20 local geo = config.geometry
local BAR_PAD = 100 local bar_spacing = geo.bar_spacing
local SEPARATOR_SPACING = 20 local separator_bar_spacing = geo.sep_spacing
----------------------------------------------------------------------------- -----------------------------------------------------------------------------
-- smartd -- smartd
@ -46,9 +46,11 @@ return function(config, main_state, common, width, point)
point.x, point.x,
y, y,
width, width,
BAR_PAD, -- TODO this isn't actually padding, it would be padding if it was
-- relative to the right edge of the text column
geo.bar_pad,
names, names,
SPACING, bar_spacing,
12, 12,
80 80
) )
@ -62,7 +64,7 @@ return function(config, main_state, common, width, point)
end end
return common.mk_acc( return common.mk_acc(
width, width,
(#config.fs_paths - 1) * SPACING, (#config.fs_paths - 1) * bar_spacing,
update, update,
pure.partial(common.compound_bar_draw_static, obj), pure.partial(common.compound_bar_draw_static, obj),
pure.partial(common.compound_bar_draw_dynamic, obj) pure.partial(common.compound_bar_draw_dynamic, obj)
@ -77,7 +79,7 @@ return function(config, main_state, common, width, point)
point = point, point = point,
width = width, width = width,
set_state = nil, set_state = nil,
top = {{mk_smart, config.show_smart, SEPARATOR_SPACING}}, top = {{mk_smart, config.show_smart, separator_bar_spacing}},
common.mk_section(SEPARATOR_SPACING, {mk_bars, true, 0}) common.mk_section(separator_bar_spacing, {mk_bars, true, 0})
} }
end end

View File

@ -2,12 +2,15 @@ local pure = require 'pure'
local i_o = require 'i_o' local i_o = require 'i_o'
return function(update_freq, config, common, width, point) return function(update_freq, config, common, width, point)
local SEPARATOR_SPACING = 20
local TEXT_SPACING = 20
local PLOT_SEC_BREAK = 20
local PLOT_HEIGHT = 56
local NA = 'N/A' local NA = 'N/A'
local NVIDIA_EXE = 'nvidia-settings' local NVIDIA_EXE = 'nvidia-settings'
local geo = config.geometry
local sep_spacing = geo.sep_spacing
local text_spacing = geo.text_spacing
local plot_sec_break = geo.plot.sec_break
local plot_height = geo.plot.height
local __string_match = string.match local __string_match = string.match
local __string_format = string.format local __string_format = string.format
local __tonumber = tonumber local __tonumber = tonumber
@ -88,8 +91,9 @@ return function(update_freq, config, common, width, point)
point.x, point.x,
y, y,
width, width,
PLOT_HEIGHT, plot_height,
PLOT_SEC_BREAK, geo.plot.ticks_y,
plot_sec_break,
label, label,
update_freq update_freq
) )
@ -102,7 +106,7 @@ return function(update_freq, config, common, width, point)
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(
width, width,
PLOT_HEIGHT + PLOT_SEC_BREAK, plot_height + plot_sec_break,
update, update,
static, static,
dynamic dynamic
@ -154,7 +158,7 @@ return function(update_freq, config, common, width, point)
point.x, point.x,
y, y,
width, width,
TEXT_SPACING, text_spacing,
{'GPU Clock Speed', 'Memory Clock Speed'} {'GPU Clock Speed', 'Memory Clock Speed'}
) )
local update = function() local update = function()
@ -168,7 +172,7 @@ return function(update_freq, config, common, 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 common.mk_acc(width, text_spacing, update, static, dynamic)
end end
----------------------------------------------------------------------------- -----------------------------------------------------------------------------
@ -206,19 +210,19 @@ return function(update_freq, config, common, width, point)
point = point, point = point,
width = width, width = width,
set_state = update_state, set_state = update_state,
top = {{mk_status, true, SEPARATOR_SPACING}}, top = {{mk_status, true, sep_spacing}},
common.mk_section( common.mk_section(
SEPARATOR_SPACING, sep_spacing,
{mk_temp, config.show_temp, SEPARATOR_SPACING} {mk_temp, config.show_temp, sep_spacing}
), ),
common.mk_section( common.mk_section(
SEPARATOR_SPACING, sep_spacing,
{mk_clock, config.show_clock, SEPARATOR_SPACING} {mk_clock, config.show_clock, sep_spacing}
), ),
common.mk_section( common.mk_section(
SEPARATOR_SPACING, sep_spacing,
{mk_gpu_util, config.show_gpu_util, PLOT_SEC_BREAK}, {mk_gpu_util, config.show_gpu_util, plot_sec_break},
{mk_mem_util, config.show_mem_util, PLOT_SEC_BREAK}, {mk_mem_util, config.show_mem_util, plot_sec_break},
{mk_vid_util, config.show_vid_util, 0} {mk_vid_util, config.show_vid_util, 0}
) )
} }

View File

@ -5,15 +5,16 @@ local pure = require 'pure'
local sys = require 'sys' local sys = require 'sys'
return function(update_freq, config, common, 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_x_spacing = 40
local CACHE_Y_OFFSET = 7 local cache_y_offset = 7
local CACHE_X_OFFSET = 50 local cache_x_offset = 50
local TEXT_SPACING = 20
local PLOT_SECTION_BREAK = 23 local geo = config.geometry
local PLOT_HEIGHT = 56 local plot_sec_break = geo.plot.sec_break
local TABLE_SECTION_BREAK = 20 local plot_height = geo.plot.height
local table_sec_break = geo.table.sec_break
local __math_floor = math.floor local __math_floor = math.floor
local __string_format = string.format local __string_format = string.format
@ -49,34 +50,34 @@ return function(update_freq, config, common, width, point)
-- mem stats (dial + text) -- mem stats (dial + text)
local mk_stats = function(y) local mk_stats = function(y)
local MEM_X = point.x + DIAL_RADIUS + DIAL_THICKNESS / 2 local mem_x = point.x + dial_radius + dial_thickness / 2
local DIAL_DIAMETER = DIAL_RADIUS * 2 + DIAL_THICKNESS local dial_diameter = dial_radius * 2 + dial_thickness
local CACHE_X local cache_x
local SWAP_X local swap_x
if _show_swap == true then if _show_swap == true then
SWAP_X = MEM_X + DIAL_DIAMETER + DIAL_SPACING swap_x = mem_x + dial_diameter + dial_x_spacing
CACHE_X = SWAP_X + CACHE_X_OFFSET + DIAL_DIAMETER / 2 cache_x = swap_x + cache_x_offset + dial_diameter / 2
else else
CACHE_X = MEM_X + CACHE_X_OFFSET + DIAL_DIAMETER / 2 cache_x = mem_x + cache_x_offset + dial_diameter / 2
end end
local CACHE_WIDTH = point.x + width - CACHE_X local cache_width = point.x + width - cache_x
local format_percent = pure.partial(__string_format, '%i%%', true) local format_percent = pure.partial(__string_format, '%i%%', true)
-- memory bits (used no matter what) -- memory bits (used no matter what)
local mem = common.make_dial( local mem = common.make_dial(
MEM_X, mem_x,
y + DIAL_RADIUS, y + dial_radius,
DIAL_RADIUS, dial_radius,
DIAL_THICKNESS, dial_thickness,
80, 80,
format_percent, format_percent,
__math_floor __math_floor
) )
local cache = common.make_text_rows_formatted( local cache = common.make_text_rows_formatted(
CACHE_X, cache_x,
y + CACHE_Y_OFFSET, y + cache_y_offset,
CACHE_WIDTH, cache_width,
TEXT_SPACING, geo.text_spacing,
{'Page Cache', 'Buffers', 'Shared', 'Kernel Slab'}, {'Page Cache', 'Buffers', 'Shared', 'Kernel Slab'},
'%.1f%%' '%.1f%%'
) )
@ -98,15 +99,15 @@ return function(update_freq, config, common, width, point)
common.dial_draw_dynamic(mem, cr) common.dial_draw_dynamic(mem, cr)
common.text_rows_draw_dynamic(cache, cr) common.text_rows_draw_dynamic(cache, cr)
end end
local ret = pure.partial(common.mk_acc, width, DIAL_DIAMETER) local ret = pure.partial(common.mk_acc, width, dial_diameter)
-- add swap bits if needed -- add swap bits if needed
if _show_swap == true then if _show_swap == true then
local swap = common.make_dial( local swap = common.make_dial(
SWAP_X, swap_x,
y + DIAL_RADIUS, y + dial_radius,
DIAL_RADIUS, dial_radius,
DIAL_THICKNESS, dial_thickness,
80, 80,
format_percent, format_percent,
__math_floor __math_floor
@ -135,12 +136,13 @@ return function(update_freq, config, common, width, point)
point.x, point.x,
y, y,
width, width,
PLOT_HEIGHT, plot_height,
geo.plot.ticks_y,
update_freq update_freq
) )
return common.mk_acc( return common.mk_acc(
width, width,
PLOT_HEIGHT, plot_height,
function() timeseries.update(obj, mod_state.mem.used_percent) end, function() timeseries.update(obj, mod_state.mem.used_percent) end,
pure.partial(timeseries.draw_static, obj), pure.partial(timeseries.draw_static, obj),
pure.partial(timeseries.draw_dynamic, obj) pure.partial(timeseries.draw_dynamic, obj)
@ -152,14 +154,15 @@ return function(update_freq, config, common, width, point)
point.x, point.x,
y, y,
width, width,
PLOT_HEIGHT, plot_height,
PLOT_SECTION_BREAK, geo.plot.ticks_y,
plot_sec_break,
"Total Memory", "Total Memory",
update_freq update_freq
) )
return common.mk_acc( return common.mk_acc(
width, width,
PLOT_HEIGHT + PLOT_SECTION_BREAK, plot_height + plot_sec_break,
function() function()
common.tagged_percent_timeseries_set( common.tagged_percent_timeseries_set(
obj, obj,
@ -216,8 +219,8 @@ return function(update_freq, config, common, width, point)
width = width, width = width,
set_state = read_state, set_state = read_state,
top = { top = {
{mk_stats, config.show_stats, PLOT_SECTION_BREAK}, {mk_stats, config.show_stats, plot_sec_break},
{mk_plot, config.show_plot, TABLE_SECTION_BREAK}, {mk_plot, config.show_plot, table_sec_break},
{mk_tbl, config.table_rows > 0, 0}, {mk_tbl, config.table_rows > 0, 0},
} }
} }

View File

@ -3,9 +3,10 @@ local pure = require 'pure'
local i_o = require 'i_o' local i_o = require 'i_o'
local sys = require 'sys' local sys = require 'sys'
return function(update_freq, common, width, point) return function(update_freq, config, common, width, point)
local PLOT_SEC_BREAK = 20 local geo = config.geometry
local PLOT_HEIGHT = 56 local plot_sec_break = geo.plot.sec_break
local plot_height = geo.plot.height
local interface_paths = sys.get_net_interface_paths() local interface_paths = sys.get_net_interface_paths()
local get_bits = function(path) local get_bits = function(path)
@ -40,10 +41,11 @@ return function(update_freq, common, width, point)
point.x, point.x,
y, y,
width, width,
PLOT_HEIGHT, plot_height,
geo.plot.ticks_y,
value_format_function, value_format_function,
common.converted_y_label_format_generator('b'), common.converted_y_label_format_generator('b'),
PLOT_SEC_BREAK, plot_sec_break,
label, label,
2, 2,
update_freq, update_freq,
@ -51,7 +53,7 @@ return function(update_freq, common, width, point)
) )
return common.mk_acc( return common.mk_acc(
width, width,
PLOT_HEIGHT + PLOT_SEC_BREAK, plot_height + plot_sec_break,
function() common.update_rate_timeseries(obj, mod_state[key]) end, function() common.update_rate_timeseries(obj, mod_state[key]) end,
pure.partial(common.tagged_scaled_timeseries_draw_static, obj), pure.partial(common.tagged_scaled_timeseries_draw_static, obj),
pure.partial(common.tagged_scaled_timeseries_draw_dynamic, obj) pure.partial(common.tagged_scaled_timeseries_draw_dynamic, obj)
@ -70,7 +72,7 @@ return function(update_freq, common, width, point)
width = width, width = width,
set_state = read_interfaces, set_state = read_interfaces,
top = { top = {
{mk_rx, true, PLOT_SEC_BREAK}, {mk_rx, true, plot_sec_break},
{mk_tx, true, 0}, {mk_tx, true, 0},
} }
} }

View File

@ -1,7 +1,7 @@
local pure = require 'pure' local pure = require 'pure'
return function(main_state, common, width, point) return function(main_state, config, common, width, point)
local TEXT_SPACING = 20 local text_spacing = config.geometry.text_spacing
local __string_match = string.match local __string_match = string.match
local __string_gmatch = string.gmatch local __string_gmatch = string.gmatch
@ -11,7 +11,7 @@ return function(main_state, common, width, point)
point.x, point.x,
y, y,
width, width,
TEXT_SPACING, text_spacing,
{'Total', 'Explicit', 'Outdated', 'Orphaned', 'Local'} {'Total', 'Explicit', 'Outdated', 'Orphaned', 'Local'}
) )
local update = function() local update = function()
@ -33,7 +33,7 @@ return function(main_state, common, width, point)
end end
return common.mk_acc( return common.mk_acc(
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),
pure.partial(common.text_rows_draw_dynamic, obj) pure.partial(common.text_rows_draw_dynamic, obj)

View File

@ -3,9 +3,9 @@ local pure = require 'pure'
local sys = require 'sys' local sys = require 'sys'
return function(update_freq, config, common, width, point) return function(update_freq, config, common, width, point)
local TEXT_SPACING = 20 local geo = config.geometry
local PLOT_SEC_BREAK = 20 local plot_sec_break = geo.plot.sec_break
local PLOT_HEIGHT = 56 local plot_height = geo.plot.height
local power_label_function = function(plot_max) local power_label_function = function(plot_max)
local fmt = common.y_label_format_string(plot_max, 'W') local fmt = common.y_label_format_string(plot_max, 'W')
@ -30,10 +30,11 @@ return function(update_freq, config, common, width, point)
point.x, point.x,
y, y,
width, width,
PLOT_HEIGHT, plot_height,
geo.plot.ticks_y,
format_rapl, format_rapl,
power_label_function, power_label_function,
PLOT_SEC_BREAK, plot_sec_break,
label, label,
0, 0,
update_freq, update_freq,
@ -41,7 +42,7 @@ return function(update_freq, config, common, width, point)
) )
return common.mk_acc( return common.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,
mk_static(obj), mk_static(obj),
mk_dynamic(obj) mk_dynamic(obj)
@ -50,7 +51,7 @@ return function(update_freq, config, common, width, point)
local mk_rate_blockspec = function(spec) local mk_rate_blockspec = function(spec)
local f = pure.partial(mk_rate_plot, spec.name, spec.address) local f = pure.partial(mk_rate_plot, spec.name, spec.address)
return {f, true, TEXT_SPACING} return {f, true, geo.text_spacing}
end end
----------------------------------------------------------------------------- -----------------------------------------------------------------------------
@ -72,17 +73,18 @@ return function(update_freq, config, common, width, point)
point.x, point.x,
y, y,
width, width,
PLOT_HEIGHT, plot_height,
geo.plot.ticks_y,
format_ac, format_ac,
power_label_function, power_label_function,
PLOT_SEC_BREAK, plot_sec_break,
'Battery Draw', 'Battery Draw',
0, 0,
update_freq update_freq
) )
return common.mk_acc( return common.mk_acc(
width, width,
PLOT_HEIGHT + PLOT_SEC_BREAK, plot_height + plot_sec_break,
function() function()
common.tagged_scaled_timeseries_set( common.tagged_scaled_timeseries_set(
obj, obj,

View File

@ -6,16 +6,17 @@ local pure = require 'pure'
local __math_floor = math.floor local __math_floor = math.floor
return function(update_freq, config, main_state, common, width, point) return function(update_freq, main_state, config, 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
local DIAL_SPACING = 20 local dial_y_spacing = 20
local SEPARATOR_SPACING = 20
local TEXT_SPACING = 22 local geo = config.geometry
local PLOT_SECTION_BREAK = 23 local sep_spacing = geo.sep_spacing
local PLOT_HEIGHT = 56 local text_spacing = geo.text_spacing
local TABLE_SECTION_BREAK = 20 local plot_sec_break = geo.plot.sec_break
local plot_height = geo.plot.height
----------------------------------------------------------------------------- -----------------------------------------------------------------------------
-- processor state -- processor state
@ -51,26 +52,26 @@ return function(update_freq, config, main_state, common, width, point)
local dial_x = point.x + local dial_x = point.x +
(core_cols == 1 (core_cols == 1
and (width / 2) and (width / 2)
or (config.core_padding + DIAL_OUTER_RADIUS + or (config.core_padding + dial_outer_radius +
(width - 2 * (DIAL_OUTER_RADIUS + config.core_padding)) (width - 2 * (dial_outer_radius + config.core_padding))
* math.fmod(c - 1, core_cols) / (core_cols - 1))) * math.fmod(c - 1, core_cols) / (core_cols - 1)))
local dial_y = y + DIAL_OUTER_RADIUS + local dial_y = y + dial_outer_radius +
(2 * DIAL_OUTER_RADIUS + DIAL_SPACING) (2 * dial_outer_radius + dial_y_spacing)
* math.floor((c - 1) / core_cols) * math.floor((c - 1) / core_cols)
return { return {
loads = common.make_compound_dial( loads = common.make_compound_dial(
dial_x, dial_x,
dial_y, dial_y,
DIAL_OUTER_RADIUS, dial_outer_radius,
DIAL_INNER_RADIUS, dial_inner_radius,
DIAL_THICKNESS, dial_thickness,
80, 80,
nthreads nthreads
), ),
coretemp = common.make_text_circle( coretemp = common.make_text_circle(
dial_x, dial_x,
dial_y, dial_y,
DIAL_INNER_RADIUS - 2, dial_inner_radius - 2,
'%s°C', '%s°C',
80, 80,
__math_floor __math_floor
@ -115,8 +116,8 @@ return function(update_freq, config, main_state, common, width, point)
end end
return common.mk_acc( return common.mk_acc(
width, width,
(DIAL_OUTER_RADIUS * 2 + DIAL_SPACING) * config.core_rows (dial_outer_radius * 2 + dial_y_spacing) * config.core_rows
- DIAL_SPACING, - dial_y_spacing,
update, update,
static, static,
dynamic dynamic
@ -132,7 +133,7 @@ return function(update_freq, config, main_state, common, width, point)
point.x, point.x,
y, y,
width, width,
TEXT_SPACING, text_spacing,
{'HWP Preference', 'Ave Freq'} {'HWP Preference', 'Ave Freq'}
) )
local update = function() local update = function()
@ -148,7 +149,7 @@ return function(update_freq, config, main_state, common, width, point)
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(
width, width,
TEXT_SPACING, text_spacing,
update, update,
static, static,
dynamic dynamic
@ -163,8 +164,9 @@ return function(update_freq, config, main_state, common, width, point)
point.x, point.x,
y, y,
width, width,
PLOT_HEIGHT, plot_height,
PLOT_SECTION_BREAK, geo.plot.ticks_y,
plot_sec_break,
"Total Load", "Total Load",
update_freq update_freq
) )
@ -177,7 +179,7 @@ return function(update_freq, config, main_state, common, width, point)
end end
return common.mk_acc( return common.mk_acc(
width, width,
PLOT_HEIGHT + PLOT_SECTION_BREAK, plot_height + plot_sec_break,
update, update,
pure.partial(common.tagged_percent_timeseries_draw_static, total_load), pure.partial(common.tagged_percent_timeseries_draw_static, total_load),
pure.partial(common.tagged_percent_timeseries_draw_dynamic, total_load) pure.partial(common.tagged_percent_timeseries_draw_dynamic, total_load)
@ -229,12 +231,12 @@ return function(update_freq, config, main_state, common, width, point)
width = width, width = width,
set_state = update_state, set_state = update_state,
top = { top = {
{mk_cores, show_cores, TEXT_SPACING}, {mk_cores, show_cores, text_spacing},
{mk_hwp_freq, config.show_stats, SEPARATOR_SPACING}, {mk_hwp_freq, config.show_stats, sep_spacing},
}, },
common.mk_section( common.mk_section(
SEPARATOR_SPACING, sep_spacing,
{mk_load_plot, config.show_plot, TABLE_SECTION_BREAK}, {mk_load_plot, config.show_plot, geo.table.sec_break},
{mk_tbl, config.table_rows > 0, 0} {mk_tbl, config.table_rows > 0, 0}
) )
} }

View File

@ -5,8 +5,9 @@ local i_o = require 'i_o'
local impure = require 'impure' local impure = require 'impure'
return function(update_freq, config, common, width, point) return function(update_freq, config, common, width, point)
local PLOT_SEC_BREAK = 20 local geo = config.geometry
local PLOT_HEIGHT = 56 local plot_sec_break = geo.plot.sec_break
local plot_height = geo.plot.height
local mod_state = {read = 0, write = 0} local mod_state = {read = 0, write = 0}
local device_paths = sys.get_disk_paths(config.devices) local device_paths = sys.get_disk_paths(config.devices)
@ -33,10 +34,11 @@ return function(update_freq, config, common, width, point)
point.x, point.x,
y, y,
width, width,
PLOT_HEIGHT, plot_height,
geo.plot.ticks_y,
format_value_function, format_value_function,
common.converted_y_label_format_generator('B'), common.converted_y_label_format_generator('B'),
PLOT_SEC_BREAK, plot_sec_break,
label, label,
2, 2,
update_freq, update_freq,
@ -44,7 +46,7 @@ return function(update_freq, config, common, width, point)
) )
return common.mk_acc( return common.mk_acc(
width, width,
PLOT_HEIGHT + PLOT_SEC_BREAK, plot_height + plot_sec_break,
function() common.update_rate_timeseries(obj, mod_state[key]) end, function() common.update_rate_timeseries(obj, mod_state[key]) end,
pure.partial(common.tagged_scaled_timeseries_draw_static, obj), pure.partial(common.tagged_scaled_timeseries_draw_static, obj),
pure.partial(common.tagged_scaled_timeseries_draw_dynamic, obj) pure.partial(common.tagged_scaled_timeseries_draw_dynamic, obj)
@ -63,7 +65,7 @@ return function(update_freq, config, common, width, point)
width = width, width = width,
set_state = update_state, set_state = update_state,
top = { top = {
{mk_reads, true, PLOT_SEC_BREAK}, {mk_reads, true, plot_sec_break},
{mk_writes, true, 0}, {mk_writes, true, 0},
} }
} }

View File

@ -1,8 +1,8 @@
local i_o = require 'i_o' local i_o = require 'i_o'
local pure = require 'pure' local pure = require 'pure'
return function(main_state, common, width, point) return function(main_state, config, common, width, point)
local TEXT_SPACING = 20 local text_spacing = config.geometry.text_spacing
local __string_match = string.match local __string_match = string.match
@ -11,7 +11,7 @@ return function(main_state, common, width, point)
point.x, point.x,
y, y,
width, width,
TEXT_SPACING, text_spacing,
{'Kernel', 'Uptime', 'Last Upgrade', 'Last Sync'} {'Kernel', 'Uptime', 'Last Upgrade', 'Last Sync'}
) )
-- just update this once -- just update this once
@ -35,7 +35,7 @@ return function(main_state, common, width, point)
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(
width, width,
TEXT_SPACING * 3, text_spacing * 3,
update, update,
static, static,
dynamic dynamic