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:
|
else:
|
||||||
config_file = str(getenv("HOME")) + "/.config/easyconf-lemonbar.yml"
|
config_file = str(getenv("HOME")) + "/.config/easyconf-lemonbar.yml"
|
||||||
|
|
||||||
bar_config, module_config_list = get_bar_config_and_module_config_list(config_file)
|
#bar_config, module_config_list = get_bar_config_and_module_config_list(config_file)
|
||||||
padding = bar_config["padding"]
|
get_bar_config_and_module_config_list(config_file)
|
||||||
seperator = bar_config["seperator"]
|
#padding = bar_config["padding"]
|
||||||
margin = bar_config["margin"]
|
#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:
|
#for module_config in module_config_list:
|
||||||
module = Module(module_config, padding, bar)
|
# module = Module(module_config, padding, bar)
|
||||||
bar.add_module(module)
|
# bar.add_module(module)
|
||||||
module.start_thread()
|
# module.start_thread()
|
||||||
if module.signal != 0:
|
# if module.signal != 0:
|
||||||
signal_router.register_signal_thread(module.signal, module.ident)
|
# 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__":
|
if __name__ == "__main__":
|
||||||
main()
|
main()
|
||||||
|
|
|
@ -20,9 +20,10 @@ def get_bar_config_and_module_config_list(filename):
|
||||||
Optional("seperator", default="|"): str,
|
Optional("seperator", default="|"): str,
|
||||||
Optional("margin", default=""): str
|
Optional("margin", default=""): str
|
||||||
},
|
},
|
||||||
"modules": [
|
"monitor": {
|
||||||
{
|
And(int, lambda n: 0 <= n <= 9): {
|
||||||
"name": str,
|
"modules": {
|
||||||
|
str: {
|
||||||
"command": str,
|
"command": str,
|
||||||
"refresh": And(int, lambda n : n >= 0),
|
"refresh": And(int, lambda n : n >= 0),
|
||||||
Optional("prefix"): str,
|
Optional("prefix"): str,
|
||||||
|
@ -42,11 +43,13 @@ def get_bar_config_and_module_config_list(filename):
|
||||||
# "activator": Or("left", "center", "right", "scrup", "scrdown"),
|
# "activator": Or("left", "center", "right", "scrup", "scrdown"),
|
||||||
# "command": str
|
# "command": str
|
||||||
#}
|
#}
|
||||||
}
|
|
||||||
}
|
|
||||||
]
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
with open(filename, "r", encoding="utf8") as file:
|
with open(filename, "r", encoding="utf8") as file:
|
||||||
|
@ -54,6 +57,7 @@ def get_bar_config_and_module_config_list(filename):
|
||||||
|
|
||||||
try:
|
try:
|
||||||
validated_config = config_schema.validate(config_file)
|
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:
|
except SchemaError as se:
|
||||||
raise se
|
raise se
|
||||||
|
|
Loading…
Reference in a new issue