diff --git a/config.yml b/config.yml index bb7ae2a..51f72a6 100644 --- a/config.yml +++ b/config.yml @@ -2,18 +2,12 @@ modules: filesystem: show_smart: true fs_paths: - - path: / - name: root - - path: /boot - name: boot - - path: /home - name: home - - path: /mnt/data - name: data - - path: /mnt/dcache - name: dcache - - path: /tmp - name: tmpfs + - {path: /, name: root} + - {path: /boot, name: boot} + - {path: /home, name: home} + - {path: /mnt/data, name: data} + - {path: /mnt/dcache, name: dcache} + - {path: /tmp, name: tmpfs} graphics: show_temp: true show_clock: true @@ -27,10 +21,8 @@ modules: power: battery: BAT0 rapl_specs: - - name: PKG0 - address: intel-rapl:0 - - name: DRAM - address: intel-rapl:0:2 + - {name: PKG0, address: intel-rapl:0} + - {name: DRAM, address: intel-rapl:0:2} processor: show_cores: true show_stats: true @@ -41,8 +33,8 @@ modules: layout: anchor: [12, 11] panels: - - !!seq [[system, 19, graphics, 16, processor]] + - [[system, 19, graphics, 16, processor]] - 10 - - !!seq [[readwrite], 20, [network]] + - [[readwrite], 20, [network]] - 10 - - !!seq [[pacman, 24, filesystem, 24, power, 19, memory]] + - [[pacman, 24, filesystem, 24, power, 19, memory]] diff --git a/drawing/static.lua b/drawing/static.lua index 67024e1..d394fbd 100644 --- a/drawing/static.lua +++ b/drawing/static.lua @@ -4,11 +4,11 @@ local geometry = require 'geometry' local geom = require 'geom' local fill_rect = require 'fill_rect' -local reduce_modules_y = function(init_x, acc, new) +local reduce_modules_y = function(modlist, init_x, acc, new) if type(new) == "number" then acc.next_y = acc.next_y + new else - local r = new(geom.make_point(init_x, acc.next_y)) + local r = modlist[new](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 @@ -16,12 +16,12 @@ local reduce_modules_y = function(init_x, acc, new) return acc end -local reduce_modules_x = function(init_y, acc, x_mods) +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, acc.next_x), + pure.partial(reduce_modules_y, modlist, acc.next_x), {next_x = acc.next_x, next_y = init_y, fgroups = acc.fgroups}, x_mods ) @@ -32,9 +32,9 @@ local reduce_modules_x = function(init_y, acc, x_mods) return acc end -local arrange_panel_modules = function(point, mods) +local arrange_panel_modules = function(modlist, point, mods) local r = pure.reduce( - pure.partial(reduce_modules_x, point.y), + pure.partial(reduce_modules_x, modlist, point.y), {next_x = point.x, next_y = point.y, fgroups = {}}, mods ) @@ -72,12 +72,12 @@ local build_surface = function(box, fs) return {x = cs_x, y = cs_y, s = cs} end -local reduce_static = function(y, margins, acc, panel_mods) +local reduce_static = function(mods, y, margins, acc, panel_mods) if type(panel_mods) == "number" then acc.next_x = acc.next_x + panel_mods else local mpoint = geom.make_point(acc.next_x + margins.x, y + margins.y) - local r = arrange_panel_modules(mpoint, panel_mods) + local r = arrange_panel_modules(mods, mpoint, panel_mods) local w = r.width + margins.x * 2 local h = r.height + margins.y * 2 local pbox = geom.make_box(acc.next_x, y, w, h) @@ -89,13 +89,14 @@ local reduce_static = function(y, margins, acc, panel_mods) return acc end -return function(point, module_sets) +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, {x = geometry.PANEL_MARGIN_X, y = geometry.PANEL_MARGIN_Y} ), diff --git a/main.lua b/main.lua index c6b907f..f40e821 100644 --- a/main.lua +++ b/main.lua @@ -15,7 +15,10 @@ package.path = ABS_PATH..'?.lua;'.. ABS_PATH..'core/widget/timeseries/?.lua;'.. ABS_PATH..'core/widget/rect/?.lua;'.. ABS_PATH..'core/widget/line/?.lua;'.. - ABS_PATH..'lib/share/lua/5.4/?.lua;' + ABS_PATH..'lib/share/lua/5.4/?.lua;'.. + ABS_PATH..'lib/share/lua/5.4/?/init.lua;' + +package.cpath = ABS_PATH..'lib/lib/lua/5.4/?.so;' local i_o = require 'i_o' local geom = require 'geom' @@ -30,7 +33,7 @@ local readwrite = require 'readwrite' local graphics = require 'graphics' local memory = require 'memory' local static = require 'static' -local yaml = require 'tinyyaml' +local yaml = require 'lyaml' local draw_dynamic @@ -41,28 +44,25 @@ function conky_start(update_interval) local main_state = {} - local config = yaml.parse(i_o.read_file(ABS_PATH..'config.yml')) + local config = yaml.load(i_o.read_file(ABS_PATH..'config.yml')) local cmods = config.modules - local mem = pure.partial(memory, update_freq, cmods.memory) - local rw = pure.partial(readwrite, update_freq, cmods.readwrite) - local net = pure.partial(network, update_freq) - local pwr = pure.partial(power, update_freq, cmods.power) - local fs = pure.partial(filesystem, cmods.filesystem, main_state) - local stm = pure.partial(system, main_state) - local gfx = pure.partial(graphics, update_freq, cmods.graphics) - local proc = pure.partial(processor, update_freq, cmods.processor, main_state) - local pcm = pure.partial(pacman, main_state) + local mods = { + memory = pure.partial(memory, update_freq, cmods.memory), + readwrite = pure.partial(readwrite, update_freq, cmods.readwrite), + network = pure.partial(network, update_freq), + power = pure.partial(power, update_freq, cmods.power), + filesystem = pure.partial(filesystem, cmods.filesystem, main_state), + system = pure.partial(system, main_state), + graphics = pure.partial(graphics, update_freq, cmods.graphics), + processor = pure.partial(processor, update_freq, cmods.processor, main_state), + pacman = pure.partial(pacman, main_state) + } local compiled = static( geom.make_point(table.unpack(config.layout.anchor)), - { - {{stm, 19, gfx, 16, proc}}, - 10, - {{rw}, 20, {net}}, - 10, - {{pcm, 24, fs, 24, pwr, 19, mem}} - } + mods, + config.layout.panels ) local STATS_FILE = '/tmp/.conky_pacman' diff --git a/schema.yml b/schema.yml index 304de5b..25b9d18 100644 --- a/schema.yml +++ b/schema.yml @@ -152,7 +152,3 @@ properties: pattern: "^system|graphics|processor|readwrite|\ network|pacman|filesystem|power|memory$" - - - -