Add RDP action type using XFreeRDP
This commit is contained in:
@@ -2,22 +2,23 @@ import subprocess
|
|||||||
import shutil
|
import shutil
|
||||||
|
|
||||||
class ActionDispatcher:
|
class ActionDispatcher:
|
||||||
def dispatch(self, service_type, target):
|
def dispatch(self, service_type, config):
|
||||||
print(f"Executing action -> Type: {service_type}, Target: {target}")
|
print(f"Executing action -> Type: {service_type}")
|
||||||
|
|
||||||
if service_type == "browser":
|
if service_type == "browser":
|
||||||
self._launch_app_browser(target)
|
self._launch_app_browser(config['target'])
|
||||||
elif service_type == "rdp":
|
elif service_type == "rdp":
|
||||||
## Refactor required to pass 'config' through to this level
|
## Refactor required to pass 'config' through to this level
|
||||||
self._launch_xfreerdp(config)
|
self._launch_xfreerdp(config)
|
||||||
elif service_type == "command":
|
elif service_type == "command":
|
||||||
self._run_command(target.split())
|
self._run_command(config['cmd'].split())
|
||||||
elif service_type == "power":
|
elif service_type == "power":
|
||||||
self._handle_power_action(target)
|
self._handle_power_action(config)
|
||||||
else:
|
else:
|
||||||
print(f"Service type: {service_type}, not known")
|
print(f"Service type: {service_type}, not known")
|
||||||
|
|
||||||
def _launch_app_browser(self, url):
|
def _launch_app_browser(self, url):
|
||||||
|
print(f"URL: {url}")
|
||||||
browser_candidates = [
|
browser_candidates = [
|
||||||
"chromium",
|
"chromium",
|
||||||
"chromium-browser",
|
"chromium-browser",
|
||||||
@@ -41,8 +42,17 @@ class ActionDispatcher:
|
|||||||
self._run_command(cmd)
|
self._run_command(cmd)
|
||||||
|
|
||||||
def _launch_xfreerdp(self, config):
|
def _launch_xfreerdp(self, config):
|
||||||
# Read config and build xfreerdp command before passing to _run_command
|
cmd = [
|
||||||
return
|
"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):
|
def _handle_power_action(self, action):
|
||||||
if action == "shutdown":
|
if action == "shutdown":
|
||||||
|
|||||||
@@ -36,16 +36,17 @@ class LauncherApp(Gtk.Application):
|
|||||||
for service in self.config.get("services", []):
|
for service in self.config.get("services", []):
|
||||||
title = service.get("title", "Service")
|
title = service.get("title", "Service")
|
||||||
desc = service.get("desc", "")
|
desc = service.get("desc", "")
|
||||||
service_type = service.get("type", "command")
|
|
||||||
target = service.get("target", "")
|
|
||||||
bg_img = service.get("bg_image", "")
|
bg_img = service.get("bg_image", "")
|
||||||
|
|
||||||
self.ui.add_card(
|
self.ui.add_card(
|
||||||
title,
|
title,
|
||||||
desc,
|
desc,
|
||||||
bg_img,
|
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)
|
self.ui.setup_exit_shortcut(self.quit)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user