Add RDP action type using XFreeRDP

This commit is contained in:
2026-08-25 19:15:44 +01:00
parent 7c9723fd95
commit 93a842ec73
2 changed files with 22 additions and 11 deletions

View File

@@ -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":

View File

@@ -36,15 +36,16 @@ 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)