reorganized config schema
This commit is contained in:
parent
09be7cd6da
commit
90bbfcd7fe
2 changed files with 43 additions and 38 deletions
|
@ -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()
|
||||
|
|
|
@ -20,32 +20,35 @@ def get_bar_config_and_module_config_list(filename):
|
|||
Optional("seperator", default="|"): str,
|
||||
Optional("margin", default=""): str
|
||||
},
|
||||
"modules": [
|
||||
{
|
||||
"name": str,
|
||||
"command": str,
|
||||
"refresh": And(int, lambda n : n >= 0),
|
||||
Optional("prefix"): str,
|
||||
Optional("signal"): And(int, lambda n : SIGRTMIN <= SIGRTMIN+n <= SIGRTMAX),
|
||||
"format": {
|
||||
"align": Or("left", "center", "right"),
|
||||
Optional("bg_color"): Regex(r'^#[0-9a-fA-F]{3}$|^#[0-9a-fA-F]{6}$|^#[0-9a-fA-F]{8}$'),
|
||||
Optional("fg_color"): Regex(r'^#[0-9a-fA-F]{3}$|^#[0-9a-fA-F]{6}$|^#[0-9a-fA-F]{8}$'),
|
||||
Optional("font"): And(int, lambda n: 1 <= n <= 5),
|
||||
Optional("offset"): int,
|
||||
Optional("line"): {
|
||||
"type": Or("underline", "overline"),
|
||||
Optional("color"): Regex(r'^#[0-9a-fA-F]{3}$|^#[0-9a-fA-F]{6}$|^#[0-9a-fA-F]{8}$')
|
||||
"monitor": {
|
||||
And(int, lambda n: 0 <= n <= 9): {
|
||||
"modules": {
|
||||
str: {
|
||||
"command": str,
|
||||
"refresh": And(int, lambda n : n >= 0),
|
||||
Optional("prefix"): str,
|
||||
Optional("signal"): And(int, lambda n : SIGRTMIN <= SIGRTMIN+n <= SIGRTMAX),
|
||||
"format": {
|
||||
"align": Or("left", "center", "right"),
|
||||
Optional("bg_color"): Regex(r'^#[0-9a-fA-F]{3}$|^#[0-9a-fA-F]{6}$|^#[0-9a-fA-F]{8}$'),
|
||||
Optional("fg_color"): Regex(r'^#[0-9a-fA-F]{3}$|^#[0-9a-fA-F]{6}$|^#[0-9a-fA-F]{8}$'),
|
||||
Optional("font"): And(int, lambda n: 1 <= n <= 5),
|
||||
Optional("offset"): int,
|
||||
Optional("line"): {
|
||||
"type": Or("underline", "overline"),
|
||||
Optional("color"): Regex(r'^#[0-9a-fA-F]{3}$|^#[0-9a-fA-F]{6}$|^#[0-9a-fA-F]{8}$')
|
||||
}
|
||||
# Not yet implemented.
|
||||
#Optional("button"): {
|
||||
# "activator": Or("left", "center", "right", "scrup", "scrdown"),
|
||||
# "command": str
|
||||
#}
|
||||
|
||||
}
|
||||
}
|
||||
# Not yet implemented.
|
||||
#Optional("button"): {
|
||||
# "activator": Or("left", "center", "right", "scrup", "scrdown"),
|
||||
# "command": str
|
||||
#}
|
||||
}
|
||||
}
|
||||
]
|
||||
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue