-------------------------------------------------------------------------------- -- set up paths local conky_dir = debug.getinfo(1).source:match("@?(.*/)") local subdirs = { '?.lua', 'drawing/?.lua', 'schema/?.lua', 'core/?.lua', 'core/widget/?.lua', 'core/widget/arc/?.lua', 'core/widget/text/?.lua', 'core/widget/timeseries/?.lua', 'core/widget/rect/?.lua', 'core/widget/line/?.lua', 'lib/share/lua/5.4/?.lua', 'lib/share/lua/5.4/?/init.lua', } for i = 1, #subdirs do subdirs[i] = conky_dir..subdirs[i] end package.path = table.concat(subdirs, ';') package.cpath = conky_dir..'lib/lib/lua/5.4/?.so;' -------------------------------------------------------------------------------- -- select global config to use (fallback to default if none found) 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(_) print('WARNING: could not validate config') return true end end local find_valid_config = function(paths) for i = 1, #paths do local path = paths[i] local r = i_o.read_file(path) if r ~= nil then if validate_config(path) then i_o.printf('INFO: Using config at %s', path) return path, yaml.load(r) else i_o.printf('WARNING: %s did not pass; trying next', path) end else i_o.printf('INFO: could not find %s; trying next', path) end end assert(false, 'ERROR: could not load valid config') end local get_config_dir = function() return (os.getenv("XDG_CONFIG_HOME") or os.getenv("HOME")..'/.config')..'/' end local try_config_paths = { get_config_dir()..'conky.ymll', conky_dir..'config/fallback.yml' } local config_path, config = find_valid_config(try_config_paths) local bootstrap = config.bootstrap local startup_hook = string.format( 'start %f %s %s %s', bootstrap.update_interval, config_path, package.path, package.cpath ) conky.config = { background = false, -- adjust cpu dial sensitivity (1-14) cpu_avg_samples = 4, net_avg_samples = 1, out_to_console = false, own_window = true, own_window_type = 'override', own_window_transparent = true, own_window_hints = 'undecorated,below,sticky,skip_taskbar,skip_pager', xinerama_head = 0, double_buffer = true, minimum_width = bootstrap.dimensions[1], minimum_height = bootstrap.dimensions[2], draw_shades = false, draw_outline = false, draw_borders = false, gap_x = 0, gap_y = 0, alignment = 'top_left', no_buffers = true, -- Lua Load lua_load = conky_dir..'main.lua', lua_draw_hook_post = 'main', lua_startup_hook = startup_hook } --control updates entirely in lua conky.text = [[]]