ENH make fallback more minimal

This commit is contained in:
Nathan Dwarshuis 2022-07-19 22:55:17 -04:00
parent 3486e37a43
commit fef6cb3c19
4 changed files with 46 additions and 61 deletions

View File

@ -2,55 +2,23 @@ bootstrap:
update_interval: 1 update_interval: 1
dimensions: [1920, 1080] dimensions: [1920, 1080]
modules: 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}
graphics:
show_temp: true
show_clock: true
show_gpu_util: true
show_mem_util: true
show_vid_util: true
memory: memory:
show_stats: true show_stats: false
show_swap: true show_swap: false
show_plot: true show_plot: true
table_rows: 5 table_rows: 3
power:
battery: BAT0
rapl_specs:
- {name: PKG0, address: intel-rapl:0}
- {name: DRAM, address: intel-rapl:0:2}
processor: processor:
core_rows: 1 core_rows: 0
core_padding: 0 core_padding: 0
show_stats: true show_stats: false
show_plot: true show_plot: true
table_rows: 5 table_rows: 3
readwrite:
devices: [sda, nvme0n1]
layout: layout:
anchor: [12, 11] anchor: [12, 11]
panels: panels:
- columns: - columns:
- {blocks: [system, 19, graphics, 16, processor], width: 436} - {blocks: [network, 10, memory, 10, processor], width: 436}
margins: [20, 10]
- 10
- columns:
- {blocks: [readwrite], width: 436}
- 20
- {blocks: [network], width: 436}
margins: [20, 10]
- 10
- columns:
- {blocks: [pacman, 24, filesystem, 23, power, 19, memory], width: 436}
margins: [20, 10] margins: [20, 10]
theme: theme:

View File

@ -20,8 +20,8 @@ properties:
type: integer type: integer
minimum: 1 minimum: 1
# NOTE none of these are required
modules: modules:
required: [filesystem, graphics, memory, power, processor, readwrite]
additionalProperties: false additionalProperties: false
properties: properties:
filesystem: filesystem:

View File

@ -32,32 +32,49 @@ 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 schema_path = conky_dir..'/config/schema.yml'
local validate_config
local try_config_paths = { if i_o.exe_exists('yajsv') then
'/home/ndwar/.config/conky.yml', validate_config = function(config_path)
conky_dir..'config/fallback.yml' local cmd = string.format('yajsv -q -s %s %s', schema_path, config_path)
} return i_o.exit_code_cmd(cmd) == 0
local config_path end
local config else
validate_config = function(_)
for i = 1, #try_config_paths do print('WARNING: could not validate config')
config_path = try_config_paths[i] return true
local r = i_o.read_file(config_path)
if r ~= nil then
config = yaml.load(r)
break
end end
end end
i_o.printf('Using config at %s', config_path) local find_valid_config = function(paths)
for i = 1, #paths do
if i_o.exit_code_cmd('command -v yajsv > /dev/null') == 0 then local path = paths[i]
local cmd = string.format('yajsv -q -s %s %s', schema_path, config_path) local r = i_o.read_file(path)
assert(i_o.exit_code_cmd(cmd) == 0, 'ERROR: config failed validation') if r ~= nil then
else if validate_config(path) then
print(string.format('WARNING: could not validate config')) 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 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 bootstrap = config.bootstrap
local startup_hook = string.format( local startup_hook = string.format(

2
core

@ -1 +1 @@
Subproject commit 8f1495175f08bdc0716ef11b73d3babb10874c8b Subproject commit 2924a6118d4fe30f3005800d65f6c378305f7c61