57 lines
1.7 KiB
Python
57 lines
1.7 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", "")
|
|
service_type = service.get("type", "command")
|
|
target = service.get("target", "")
|
|
bg_img = service.get("bg_image", "")
|
|
|
|
self.ui.add_card(
|
|
title,
|
|
desc,
|
|
bg_img,
|
|
lambda t=service_type, tgt=target: self.dispatcher.dispatch(t, tgt),
|
|
)
|
|
|
|
self.ui.setup_exit_shortcut(self.quit)
|
|
|
|
self.ui.present(self)
|
|
|
|
|
|
if __name__ == "__main__":
|
|
app = LauncherApp()
|
|
sys.exit(app.run(sys.argv)) |