diff options
| author | Kurt Himebauch <136133082+xXJSONDeruloXx@users.noreply.github.com> | 2026-09-10 15:37:05 -0400 |
|---|---|---|
| committer | Kurt Himebauch <136133082+xXJSONDeruloXx@users.noreply.github.com> | 2026-09-10 15:37:05 -0400 |
| commit | c9d1c1980b415c3710f3e049cfcbd6a0cd90977a (patch) | |
| tree | 7d1e58d65d0305446da870ef1f61362215039571 /py_modules | |
| parent | 66ca1fdf555f9f17671bcac9d25c909c8aad0e9a (diff) | |
| download | decky-lsfg-vk-c9d1c1980b415c3710f3e049cfcbd6a0cd90977a.tar.gz decky-lsfg-vk-c9d1c1980b415c3710f3e049cfcbd6a0cd90977a.zip | |
refactor: reduce flatpak shortcut detection
Diffstat (limited to 'py_modules')
| -rw-r--r-- | py_modules/lsfg_vk/steam_service.py | 37 |
1 files changed, 13 insertions, 24 deletions
diff --git a/py_modules/lsfg_vk/steam_service.py b/py_modules/lsfg_vk/steam_service.py index a952fcb..df6e3a2 100644 --- a/py_modules/lsfg_vk/steam_service.py +++ b/py_modules/lsfg_vk/steam_service.py @@ -10,7 +10,6 @@ from .constants import ( WRAPPER_FILENAME, ) -_FLATPAK_APP_ID = re.compile(r"^[A-Za-z0-9][A-Za-z0-9-]*(?:\.[A-Za-z0-9][A-Za-z0-9-]*)+$") _WRAPPER_TOKEN = f"~/{WRAPPER_FILENAME}" @@ -30,27 +29,17 @@ def _is_managed_wrapper(value: str) -> bool: return path.is_absolute() and path.name == WRAPPER_FILENAME -def classify_shortcut_transport(executable: Optional[str], launch_options: Optional[str] = None) -> Dict[str, object]: - executable_tokens = _split_command(executable) - option_tokens = _split_command(launch_options) - if executable_tokens is None or option_tokens is None or not executable_tokens: - return {"kind": "host"} - direct_flatpak = executable_tokens[0] in {"flatpak", "/usr/bin/flatpak"} - managed_wrapper = len(executable_tokens) == 1 and _is_managed_wrapper(executable_tokens[0]) - if not direct_flatpak and not managed_wrapper: - return {"kind": "host"} - arguments = [*executable_tokens[1:], *option_tokens] - if not arguments or arguments[0] != "run": - return {"kind": "host"} - for argument in arguments[1:]: - if argument == "--" or argument.startswith("-"): - continue - return ( - {"kind": "flatpak", "flatpakAppId": argument} - if _FLATPAK_APP_ID.fullmatch(argument) - else {"kind": "host"} - ) - return {"kind": "host"} +def is_direct_flatpak_shortcut(executable: Optional[str]) -> bool: + tokens = _split_command(executable) + if not tokens: + return False + if tokens[0] in {"flatpak", "/usr/bin/flatpak"}: + return True + return ( + len(tokens) == 2 + and _is_managed_wrapper(tokens[0]) + and tokens[1] == "/usr/bin/flatpak" + ) def _first_string(values: Dict[str, object], *keys: str) -> Optional[str]: @@ -154,7 +143,7 @@ class SteamService(BaseService): "appid": str(appid & 0xFFFFFFFF), "name": name, "nonSteam": True, - "transport": classify_shortcut_transport(executable, arguments), + "directFlatpak": is_direct_flatpak_shortcut(executable), } for key, value in (("executable", executable), ("arguments", arguments), ("startDir", start_dir)): if value is not None: @@ -309,7 +298,7 @@ class SteamService(BaseService): "appid": appid, "name": self._section_value(content, "AppState", "name") or f"App {appid}", "nonSteam": False, - "transport": {"kind": "host"}, + "directFlatpak": False, } for game in self._shortcut_games(): games.setdefault(str(game["appid"]), game) |
