2023-04-02 21:06:37 +00:00
|
|
|
from os import getenv
|
2023-04-02 19:37:33 +00:00
|
|
|
from signal import SIGTERM, signal
|
|
|
|
from pidfile import delete_pidfile, pidfile_name, create_pidfile
|
2023-04-02 21:06:37 +00:00
|
|
|
from os.path import exists
|
2023-03-13 01:35:54 +00:00
|
|
|
from SignalRouter import SignalRouter
|
2023-03-11 23:52:47 +00:00
|
|
|
from Bar import Bar
|
2023-03-11 22:51:30 +00:00
|
|
|
from Module import Module
|
2023-04-03 20:58:45 +00:00
|
|
|
from parse_config_file import get_bar_config_and_monitor_list
|
2023-02-12 20:09:01 +00:00
|
|
|
|
2023-04-02 19:37:33 +00:00
|
|
|
def sigterm_handler(signal, frame):
|
|
|
|
delete_pidfile(pidfile_name())
|
|
|
|
exit()
|
|
|
|
|
2023-03-11 22:51:30 +00:00
|
|
|
def main():
|
2023-04-02 21:06:37 +00:00
|
|
|
if exists("./data/testing_config.yml"):
|
|
|
|
config_file = "./data/testing_config.yml"
|
|
|
|
else:
|
|
|
|
config_file = str(getenv("HOME")) + "/.config/easyconf-lemonbar.yml"
|
|
|
|
|
2023-04-03 20:58:45 +00:00
|
|
|
bar_config, monitor_list = get_bar_config_and_monitor_list(config_file)
|
|
|
|
padding = bar_config["padding"]
|
|
|
|
seperator = bar_config["seperator"]
|
|
|
|
margin = bar_config["margin"]
|
2023-03-11 23:09:12 +00:00
|
|
|
|
2023-04-03 20:58:45 +00:00
|
|
|
signal_router = SignalRouter()
|
2023-03-13 01:35:54 +00:00
|
|
|
|
2023-04-03 20:58:45 +00:00
|
|
|
bar = Bar(seperator, margin)
|
2023-03-11 23:09:12 +00:00
|
|
|
|
2023-04-03 20:58:45 +00:00
|
|
|
for monitor in monitor_list:
|
|
|
|
bar.add_monitor(monitor)
|
|
|
|
module_config_list = monitor_list[monitor]["modules"]
|
|
|
|
for module_config in module_config_list.values():
|
|
|
|
module = Module(module_config, padding, bar)
|
|
|
|
bar.add_module(monitor, module)
|
|
|
|
module.start_thread()
|
|
|
|
if module.signal != 0:
|
|
|
|
signal_router.register_signal_thread(module.signal, module.ident)
|
2023-02-12 20:09:01 +00:00
|
|
|
|
2023-04-03 20:58:45 +00:00
|
|
|
create_pidfile(pidfile_name())
|
2023-02-12 20:09:01 +00:00
|
|
|
|
2023-04-03 20:58:45 +00:00
|
|
|
signal(SIGTERM, sigterm_handler)
|
2023-02-12 20:09:01 +00:00
|
|
|
|
|
|
|
if __name__ == "__main__":
|
|
|
|
main()
|