2022-07-20 00:25:19 -04:00
|
|
|
--------------------------------------------------------------------------------
|
|
|
|
-- Loading Sequence Overview
|
|
|
|
--
|
|
|
|
-- Since this is the most over-engineered conky config ever (actually probably),
|
|
|
|
-- here are the approximate loading steps:
|
|
|
|
--
|
|
|
|
-- 1. bootstrap (this file)
|
|
|
|
-- 1. set up paths
|
|
|
|
-- 2. find valid config (a yaml file, see convoluted reasoning below)
|
|
|
|
-- 3. set up conky variables
|
|
|
|
-- 2. run startup hook which does some insane dark magic including
|
|
|
|
-- 1. arranging all modules on the screen
|
|
|
|
-- 2. 'compiling' super fast functions that don't make computer lag
|
|
|
|
-- 3. pre-drawing all the crap that doesn't change
|
|
|
|
-- 4. checking various paths/exes so things don't crash for unknown reasons
|
|
|
|
-- 3. run main loop
|
|
|
|
--
|
|
|
|
-- NOTE: For all brave souls/AIs trying to understand this program, the biggest
|
|
|
|
-- 'hack' is the fact that this file (conky.conf) is actually not really a
|
|
|
|
-- config file. The 'real' config file is a yaml file which is validated
|
|
|
|
-- using a yaml schema. This file is effectively a bootstrap file, but it is
|
|
|
|
-- not meant to be 'configured' when migrating to a new machine.
|
|
|
|
--
|
|
|
|
-- Why bother doing this? Because I got tired of hacking my hard-coded config
|
|
|
|
-- when switching to different machines.
|
|
|
|
|
2022-07-19 19:15:26 -04:00
|
|
|
--------------------------------------------------------------------------------
|
|
|
|
-- set up paths
|
2021-07-16 23:25:44 -04:00
|
|
|
|
2022-07-19 18:11:46 -04:00
|
|
|
local conky_dir = debug.getinfo(1).source:match("@?(.*/)")
|
2022-07-19 19:15:26 -04:00
|
|
|
local subdirs = {
|
2022-07-20 00:11:03 -04:00
|
|
|
'src/?.lua',
|
|
|
|
'src/modules/?.lua',
|
|
|
|
'src/widget/?.lua',
|
|
|
|
'src/widget/arc/?.lua',
|
|
|
|
'src/widget/text/?.lua',
|
|
|
|
'src/widget/timeseries/?.lua',
|
|
|
|
'src/widget/rect/?.lua',
|
|
|
|
'src/widget/line/?.lua',
|
2022-07-19 19:15:26 -04:00
|
|
|
'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'
|
|
|
|
|
2022-08-11 00:05:06 -04:00
|
|
|
-- 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)
|
|
|
|
print(path)
|
|
|
|
local cmd = string.format('dhall-to-yaml --file %s > %s', path, config_path)
|
|
|
|
return i_o.exit_code_cmd(cmd)
|
2022-07-19 19:15:26 -04:00
|
|
|
end
|
|
|
|
|
2022-07-19 22:55:17 -04:00
|
|
|
local find_valid_config = function(paths)
|
|
|
|
for i = 1, #paths do
|
|
|
|
local path = paths[i]
|
2022-08-11 00:05:06 -04:00
|
|
|
local rc = try_read_config(path)
|
|
|
|
if rc == 0 then
|
|
|
|
i_o.infof('Using config at %s', path)
|
|
|
|
return yaml.load(i_o.read_file(config_path))
|
2022-07-19 22:55:17 -04:00
|
|
|
else
|
2022-08-11 00:05:06 -04:00
|
|
|
i_o.warnf('could not read %s; trying next', path)
|
2022-07-19 22:55:17 -04:00
|
|
|
end
|
|
|
|
end
|
2022-08-11 00:05:06 -04:00
|
|
|
i_o.assertf(false, 'could not load valid config')
|
2022-07-19 22:55:17 -04:00
|
|
|
end
|
2022-07-19 19:15:26 -04:00
|
|
|
|
2022-07-19 22:55:17 -04:00
|
|
|
local get_config_dir = function()
|
|
|
|
return (os.getenv("XDG_CONFIG_HOME") or os.getenv("HOME")..'/.config')..'/'
|
2022-07-19 19:15:26 -04:00
|
|
|
end
|
|
|
|
|
2022-07-19 22:55:17 -04:00
|
|
|
local try_config_paths = {
|
2022-08-11 00:05:06 -04:00
|
|
|
get_config_dir()..'conky.dhall',
|
|
|
|
conky_dir..'config/fallback.dhall'
|
2022-07-19 22:55:17 -04:00
|
|
|
}
|
|
|
|
|
2022-08-11 00:05:06 -04:00
|
|
|
local config = find_valid_config(try_config_paths)
|
2022-07-19 22:55:17 -04:00
|
|
|
|
2022-07-19 19:15:26 -04:00
|
|
|
local bootstrap = config.bootstrap
|
|
|
|
|
|
|
|
local startup_hook = string.format(
|
|
|
|
'start %f %s %s %s',
|
|
|
|
bootstrap.update_interval,
|
|
|
|
config_path,
|
|
|
|
package.path,
|
|
|
|
package.cpath
|
|
|
|
)
|
2022-07-19 18:11:46 -04:00
|
|
|
|
2016-08-11 23:25:56 -04:00
|
|
|
conky.config = {
|
2017-07-16 23:49:27 -04:00
|
|
|
background = false,
|
2016-08-11 23:25:56 -04:00
|
|
|
|
2022-07-17 23:09:04 -04:00
|
|
|
-- adjust cpu dial sensitivity (1-14)
|
2016-08-11 23:25:56 -04:00
|
|
|
cpu_avg_samples = 4,
|
2019-10-25 22:08:22 -04:00
|
|
|
net_avg_samples = 1,
|
2016-08-11 23:25:56 -04:00
|
|
|
|
|
|
|
out_to_console = false,
|
|
|
|
|
|
|
|
own_window = true,
|
2020-03-15 12:05:08 -04:00
|
|
|
own_window_type = 'override',
|
2016-08-11 23:25:56 -04:00
|
|
|
own_window_transparent = true,
|
|
|
|
own_window_hints = 'undecorated,below,sticky,skip_taskbar,skip_pager',
|
2022-07-17 23:09:04 -04:00
|
|
|
xinerama_head = 0,
|
2016-08-11 23:25:56 -04:00
|
|
|
|
|
|
|
double_buffer = true,
|
2022-08-11 00:05:06 -04:00
|
|
|
minimum_width = bootstrap.dimensions.x,
|
|
|
|
minimum_height = bootstrap.dimensions.y,
|
2016-08-11 23:25:56 -04:00
|
|
|
|
|
|
|
draw_shades = false,
|
|
|
|
draw_outline = false,
|
|
|
|
draw_borders = false,
|
|
|
|
gap_x = 0,
|
|
|
|
gap_y = 0,
|
|
|
|
alignment = 'top_left',
|
|
|
|
|
|
|
|
no_buffers = true,
|
|
|
|
|
2022-07-17 23:09:04 -04:00
|
|
|
-- Lua Load
|
2022-07-19 18:11:46 -04:00
|
|
|
lua_load = conky_dir..'main.lua',
|
2021-07-16 23:25:44 -04:00
|
|
|
lua_draw_hook_post = 'main',
|
2022-07-19 19:15:26 -04:00
|
|
|
lua_startup_hook = startup_hook
|
2016-08-11 23:25:56 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
--control updates entirely in lua
|
|
|
|
|
|
|
|
conky.text = [[]]
|
|
|
|
|