49 lines
1.3 KiB
Python
49 lines
1.3 KiB
Python
# main.py
|
|
import sys
|
|
import gi
|
|
|
|
gi.require_version("Gtk", "4.0")
|
|
from gi.repository import Gtk
|
|
|
|
from actions import ActionDispatcher
|
|
from checks import SystemChecks
|
|
from config import load_launcher_config
|
|
from ui import UIController
|
|
|
|
class LauncherApp(Gtk.Application):
|
|
def __init__(self):
|
|
super().__init__(application_id="com.local.Launcher")
|
|
|
|
self.config = load_launcher_config()
|
|
|
|
check_cfg = self.config.get("checks", {})
|
|
|
|
self.checks = SystemChecks(
|
|
network_targets=check_cfg.get("network_targets"),
|
|
ziti_target=check_cfg.get("ziti_target"),
|
|
)
|
|
self.dispatcher = ActionDispatcher()
|
|
|
|
self.ui = UIController(
|
|
system_checks=self.checks,
|
|
power_action_callback=self.dispatcher.dispatch,
|
|
service_action_callback=self.dispatcher.dispatch,
|
|
services=self.config.get("services", []),
|
|
)
|
|
|
|
def do_activate(self):
|
|
self.checks.start()
|
|
|
|
self.ui.set_app_title(self.config.get("app_title", "Launcher"))
|
|
|
|
self.ui.setup_exit_shortcut(self.quit)
|
|
|
|
self.ui.present(self)
|
|
|
|
def do_shutdown(self):
|
|
self.checks.stop()
|
|
Gtk.Application.do_shutdown(self)
|
|
|
|
if __name__ == "__main__":
|
|
app = LauncherApp()
|
|
sys.exit(app.run(sys.argv)) |