Files
thinlauncher/launcher/main.py

58 lines
1.6 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(
status_provider_callback=lambda: {
"net": self.checks.check_network_status(),
"ziti": self.checks.check_ziti_status(),
},
power_action_callback=self.dispatcher.dispatch,
)
def do_activate(self):
self.ui.set_app_title(self.config.get("app_title", "Launcher"))
for service in self.config.get("services", []):
title = service.get("title", "Service")
desc = service.get("desc", "")
bg_img = service.get("bg_image", "")
self.ui.add_card(
title,
desc,
bg_img,
lambda svc=service: self.dispatcher.dispatch(
svc.get("type", "command"),
svc,
),
)
self.ui.setup_exit_shortcut(self.quit)
self.ui.present(self)
if __name__ == "__main__":
app = LauncherApp()
sys.exit(app.run(sys.argv))