From f4275dd46594a9922021ab968be795a019895660 Mon Sep 17 00:00:00 2001 From: Boris Yumankulov Date: Tue, 2 Dec 2025 18:44:47 +0500 Subject: [PATCH] fix(get_portproton_start_command): Check if flatpak command exists before trying to run it Signed-off-by: Boris Yumankulov --- portprotonqt/config_utils.py | 40 +++++++++++++++++++++++++----------- 1 file changed, 28 insertions(+), 12 deletions(-) diff --git a/portprotonqt/config_utils.py b/portprotonqt/config_utils.py index 71e8c0d..7a93de0 100644 --- a/portprotonqt/config_utils.py +++ b/portprotonqt/config_utils.py @@ -183,23 +183,39 @@ def get_portproton_start_command(): if not portproton_path: return None + # Check if flatpak command exists before trying to run it try: - result = subprocess.run( - ["flatpak", "list"], + subprocess.run( + ["flatpak", "--version"], capture_output=True, text=True, check=False, - timeout=10 + timeout=5 ) - if "ru.linux_gaming.PortProton" in result.stdout: - logger.info("Detected Flatpak installation") - return ["flatpak", "run", "ru.linux_gaming.PortProton"] - except subprocess.TimeoutExpired: - logger.warning("Flatpak list command timed out") - return None - except Exception as e: - logger.warning(f"Error checking flatpak list: {e}") - pass + flatpak_available = True + except FileNotFoundError: + flatpak_available = False + except Exception: + flatpak_available = False + + if flatpak_available: + try: + result = subprocess.run( + ["flatpak", "list"], + capture_output=True, + text=True, + check=False, + timeout=10 + ) + if "ru.linux_gaming.PortProton" in result.stdout: + logger.info("Detected Flatpak installation") + return ["flatpak", "run", "ru.linux_gaming.PortProton"] + except subprocess.TimeoutExpired: + logger.warning("Flatpak list command timed out") + return None + except Exception as e: + logger.warning(f"Error checking flatpak list: {e}") + pass start_sh_path = os.path.join(portproton_path, "data", "scripts", "start.sh") if os.path.exists(start_sh_path):