diff --git a/launcher/actions.py b/launcher/actions.py index 8136efe..fb14ac2 100644 --- a/launcher/actions.py +++ b/launcher/actions.py @@ -2,22 +2,23 @@ import subprocess import shutil class ActionDispatcher: - def dispatch(self, service_type, target): - print(f"Executing action -> Type: {service_type}, Target: {target}") + def dispatch(self, service_type, config): + print(f"Executing action -> Type: {service_type}") if service_type == "browser": - self._launch_app_browser(target) + self._launch_app_browser(config['target']) elif service_type == "rdp": ## Refactor required to pass 'config' through to this level self._launch_xfreerdp(config) elif service_type == "command": - self._run_command(target.split()) + self._run_command(config['cmd'].split()) elif service_type == "power": - self._handle_power_action(target) + self._handle_power_action(config) else: print(f"Service type: {service_type}, not known") def _launch_app_browser(self, url): + print(f"URL: {url}") browser_candidates = [ "chromium", "chromium-browser", @@ -41,8 +42,17 @@ class ActionDispatcher: self._run_command(cmd) def _launch_xfreerdp(self, config): - # Read config and build xfreerdp command before passing to _run_command - return + cmd = [ + "xfreerdp", + f"/v:{config['target']}", + f"/u:{config['user']}", + f"/p:{config['password']}", + "/sound", + "/scale-desktop:133", + "/audio-mode:0", + "/f" + ] + self._run_command(cmd) def _handle_power_action(self, action): if action == "shutdown": diff --git a/launcher/main.py b/launcher/main.py index 6bc7602..332583d 100644 --- a/launcher/main.py +++ b/launcher/main.py @@ -36,16 +36,17 @@ class LauncherApp(Gtk.Application): 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), - ) + lambda svc=service: self.dispatcher.dispatch( + svc.get("type", "command"), + svc, + ), + ) self.ui.setup_exit_shortcut(self.quit)