From c09097491f47892d5d44e81adf5846dbc6cac2ba Mon Sep 17 00:00:00 2001 From: Quinn64 Date: Wed, 25 Oct 2023 17:22:14 -0500 Subject: [PATCH] Added support for Flatpak custom commands (#5090) --- lutris/runners/flatpak.py | 11 ++++++----- lutris/util/flatpak.py | 4 +++- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/lutris/runners/flatpak.py b/lutris/runners/flatpak.py index ce8270ef5..bf5100862 100644 --- a/lutris/runners/flatpak.py +++ b/lutris/runners/flatpak.py @@ -62,7 +62,7 @@ class flatpak(Runner): "help": _("Arguments to be passed to the application.") }, { - "option": "command", + "option": "fcommand", "type": "string", "label": _("Command"), "help": _("The command to run instead of the one listed in the application metadata."), @@ -108,10 +108,10 @@ class flatpak(Runner): def game_path(self): if shutil.which("flatpak-spawn"): return "/" - install_type, application, arch, branch = ( - self.game_config.get(key, "") for key in ("install_type", "appid", "arch", "branch") + install_type, application, arch, fcommand, branch = ( + self.game_config.get(key, "") for key in ("install_type", "appid", "arch", "fcommand", "branch") ) - return os.path.join(self.install_locations[install_type or "user"], application, arch, branch) + return os.path.join(self.install_locations[install_type or "user"], application, arch, fcommand, branch) def remove_game_data(self, app_id=None, game_path=None, **kwargs): if not self.is_installed(): @@ -129,6 +129,7 @@ class flatpak(Runner): branch = self.game_config.get("branch", "") args = self.game_config.get("args", "") appid = self.game_config.get("appid", "") + fcommand = self.game_config.get("fcommand", "") if not appid: return {"error": "CUSTOM", "text": "No application specified."} @@ -140,7 +141,7 @@ class flatpak(Runner): if any(x in appid for x in ("--", "/")): return {"error": "CUSTOM", "text": "Application ID field must not contain options or arguments."} - command = _flatpak.get_run_command(appid, arch, branch) + command = _flatpak.get_run_command(appid, arch, fcommand, branch) if args: command.extend(split_arguments(args)) return {"command": command} diff --git a/lutris/util/flatpak.py b/lutris/util/flatpak.py index 068598d11..ffc674073 100644 --- a/lutris/util/flatpak.py +++ b/lutris/util/flatpak.py @@ -64,12 +64,14 @@ def is_app_installed(appid): return False -def get_run_command(appid, arch=None, branch=None): +def get_run_command(appid, arch=None, fcommand=None, branch=None): """Return command to launch a Flatpak app""" command = get_command() command.append("run") if arch: command.append(f"--arch={arch}") + if fcommand: + command.append(f"--command={fcommand}") if branch: command.append(f"--branch={branch}") command.append(appid)