From 40678a8e17a4f1e2fa5bcc948a5812d63512d812 Mon Sep 17 00:00:00 2001 From: ndwarshuis Date: Thu, 11 Aug 2022 00:31:09 -0400 Subject: [PATCH] REF add some nice comments --- conky.conf | 15 --------------- src/color.lua | 10 +++++++--- 2 files changed, 7 insertions(+), 18 deletions(-) diff --git a/conky.conf b/conky.conf index 9781c55..f8bca59 100644 --- a/conky.conf +++ b/conky.conf @@ -55,21 +55,6 @@ package.cpath = conky_dir..'lib/lib/lua/5.4/?.so;' local yaml = require 'lyaml' local i_o = require 'i_o' --- local schema_path = conky_dir..'/config/schema.yml' --- local validate_config - --- if i_o.exe_exists('yajsv') then --- validate_config = function(config_path) --- local cmd = string.format('yajsv -q -s %s %s', schema_path, config_path) --- return i_o.exit_code_cmd(cmd) == 0 --- end --- else --- validate_config = function(_) --- i_o.warnf('could not validate config') --- return true --- end --- end - local config_path = '/tmp/conky.yml' local try_read_config = function(path) diff --git a/src/color.lua b/src/color.lua index cbc54ca..10d7656 100644 --- a/src/color.lua +++ b/src/color.lua @@ -61,19 +61,23 @@ local compile_patterns compile_patterns = function(patterns) local r = {} for k, v in pairs(patterns) do + -- number -> solid color if type(v) == "number" then r[k] = rgb(v) + -- { color = x, alpha = y} -> alpha color elseif v.color ~= nil then r[k] = rgba(v.color, v.alpha) + -- ASSUME non-empty array is a gradient elseif #v > 0 then + -- ASSUME alpha gradient will have color/stop/alpha records for each + -- member, so just check the first if v[1].alpha ~= nil then r[k] = compile_gradient_alpha(v) else - -- for k, v in pairs(compile_gradient(v)) do - -- print(k, v.r) - -- end r[k] = compile_gradient(v) end + -- ASSUME nothing else in the tree is a number, a table with 'color', or + -- an array else r[k] = compile_patterns(v) end