reorganized config schema

This commit is contained in:
Noah Swerhun 2023-04-03 14:41:32 -05:00
parent 09be7cd6da
commit 90bbfcd7fe
2 changed files with 43 additions and 38 deletions

View file

@ -17,25 +17,26 @@ def main():
else:
config_file = str(getenv("HOME")) + "/.config/easyconf-lemonbar.yml"
bar_config, module_config_list = get_bar_config_and_module_config_list(config_file)
padding = bar_config["padding"]
seperator = bar_config["seperator"]
margin = bar_config["margin"]
#bar_config, module_config_list = get_bar_config_and_module_config_list(config_file)
get_bar_config_and_module_config_list(config_file)
#padding = bar_config["padding"]
#seperator = bar_config["seperator"]
#margin = bar_config["margin"]
signal_router = SignalRouter()
#signal_router = SignalRouter()
bar = Bar(seperator, margin)
#bar = Bar(seperator, margin)
for module_config in module_config_list:
module = Module(module_config, padding, bar)
bar.add_module(module)
module.start_thread()
if module.signal != 0:
signal_router.register_signal_thread(module.signal, module.ident)
#for module_config in module_config_list:
# module = Module(module_config, padding, bar)
# bar.add_module(module)
# module.start_thread()
# if module.signal != 0:
# signal_router.register_signal_thread(module.signal, module.ident)
create_pidfile(pidfile_name())
#create_pidfile(pidfile_name())
signal(SIGTERM, sigterm_handler)
#signal(SIGTERM, sigterm_handler)
if __name__ == "__main__":
main()

View file

@ -20,9 +20,10 @@ def get_bar_config_and_module_config_list(filename):
Optional("seperator", default="|"): str,
Optional("margin", default=""): str
},
"modules": [
{
"name": str,
"monitor": {
And(int, lambda n: 0 <= n <= 9): {
"modules": {
str: {
"command": str,
"refresh": And(int, lambda n : n >= 0),
Optional("prefix"): str,
@ -42,11 +43,13 @@ def get_bar_config_and_module_config_list(filename):
# "activator": Or("left", "center", "right", "scrup", "scrdown"),
# "command": str
#}
}
}
]
}
}
}
}
}
}
})
with open(filename, "r", encoding="utf8") as file:
@ -54,6 +57,7 @@ def get_bar_config_and_module_config_list(filename):
try:
validated_config = config_schema.validate(config_file)
return validated_config["bar"]["config"], validated_config["bar"]["modules"]
return validated_config
#return validated_config["bar"]["config"], validated_config["bar"]["modules"]
except SchemaError as se:
raise se