From 9cecd528e89f993f8e910716d25c32b6b304b485 Mon Sep 17 00:00:00 2001 From: Kurt Himebauch <136133082+xXJSONDeruloXx@users.noreply.github.com> Date: Sun, 25 Oct 2026 11:50:44 -0400 Subject: [PATCH] fix: Start without Steam uses the launch options set in Steam's Properties (#1552) * fix: Start without Steam uses the launch options set in Steam's Properties * fix: treat a malformed shortcuts.vdf as having no launch options --- .../launcher/session/NoSteamLaunch.kt | 4 +- .../launcher/session/NoSteamLaunchTest.kt | 2 + .../usr/local/bin/droiddeck-proton-run | 41 ++++++++++++++++++- tools/tests/test_desktop_open.py | 37 +++++++++++++++++ 4 files changed, 81 insertions(+), 3 deletions(-) diff --git a/app/src/main/java/com/droiddeck/launcher/session/NoSteamLaunch.kt b/app/src/main/java/com/droiddeck/launcher/session/NoSteamLaunch.kt index 6787d92d22..c77e8dc161 100644 --- a/app/src/main/java/com/droiddeck/launcher/session/NoSteamLaunch.kt +++ b/app/src/main/java/com/droiddeck/launcher/session/NoSteamLaunch.kt @@ -37,7 +37,9 @@ object NoSteamLaunch { fun addedCommand(game: AddedGames.Game): Command = Command( PROTON_RUN, - listOf("--app", (game.appId and 0xFFFFFFFFL).toString(), "--dir", game.guestDir, "--options", game.launchOptions, "--", game.guestExe), + listOf("--app", (game.appId and 0xFFFFFFFFL).toString(), "--dir", game.guestDir) + + (if (game.launchOptions.isEmpty()) emptyList() else listOf("--options", game.launchOptions)) + + listOf("--", game.guestExe), game.name, ) diff --git a/app/src/test/java/com/droiddeck/launcher/session/NoSteamLaunchTest.kt b/app/src/test/java/com/droiddeck/launcher/session/NoSteamLaunchTest.kt index 84c995ee23..d0739df4ae 100644 --- a/app/src/test/java/com/droiddeck/launcher/session/NoSteamLaunchTest.kt +++ b/app/src/test/java/com/droiddeck/launcher/session/NoSteamLaunchTest.kt @@ -61,6 +61,8 @@ class NoSteamLaunchTest { listOf("--app", "2733369024", "--dir", game.guestDir, "--options", "-windowed", "--", game.guestExe), added.args, ) + val plain = NoSteamLaunch.addedCommand(AddedGames.Game(game.folder, game.name, game.exe, game.guestExe, game.guestDir, 2733369024L, 0L, emptyList(), source = "gog")) + assertEquals(listOf("--app", "2733369024", "--dir", game.guestDir, "--", game.guestExe), plain.args) assertNull(NoSteamLaunch.command(shortcut, null)) val steam = NoSteamLaunch.command(steamGame, null)!! assertEquals(listOf("--app", "413150"), steam.args) diff --git a/tools/linuxfs/overlay/usr/local/bin/droiddeck-proton-run b/tools/linuxfs/overlay/usr/local/bin/droiddeck-proton-run index 5d59829bf1..8d0805a878 100644 --- a/tools/linuxfs/overlay/usr/local/bin/droiddeck-proton-run +++ b/tools/linuxfs/overlay/usr/local/bin/droiddeck-proton-run @@ -13,7 +13,8 @@ the STEAM_COMPAT_* environment - so its wrapper applies the game's settings, com --window keeps the program in the desktop's own window, drawn with WineD3D. --app starts one game without the Steam client (its Start without Steam): a Steam game's default Windows launch option from appinfo.vdf when no program is given, else the program in that -shortcut's own prefix, started in --dir with the shortcut's launch options (--options). +shortcut's own prefix, started in --dir with the shortcut's launch options (--options). Without +--options it takes the launch options set in the client's Properties for that game or shortcut. """ import json import os @@ -230,6 +231,40 @@ def shortcut_entries(root): return entries +def vdf_string(token): + return re.sub(r'\\(.)', r'\1', token[1:-1]) if token.startswith('"') else "" + + +def steam_options(app, root): + """The launch options the client keeps for a game (localconfig.vdf) or a shortcut (shortcuts.vdf).""" + try: + tool = runpy.run_path(os.path.join(BIN_DIR, "droiddeck-steam-shortcuts")) + account = tool["account_dir"](root) + if not account: + return "" + if int(app) >= STEAM_APP_LIMIT: + with open(os.path.join(account, "config", "shortcuts.vdf"), "rb") as f: + shortcuts = tool["parse"](f.read()).get("shortcuts", {}) + for value in shortcuts.values(): + if isinstance(value, dict) and (value.get("appid", value.get("AppId")) or 0) & 0xFFFFFFFF == int(app): + options = value.get("LaunchOptions", value.get("launchoptions", "")) + return options if isinstance(options, str) else "" + return "" + tokens = compat()["tokenize"](read_text(os.path.join(account, "config", "localconfig.vdf")) or "") + start = compat()["find_block"](tokens, ["UserLocalConfigStore", "Software", "Valve", "Steam", "apps", app]) + if start is None: + return "" + end, depth = compat()["block_end"](tokens, start), 0 + for i in range(start + 1, end): + if tokens[i] in ("{", "}"): + depth += 1 if tokens[i] == "{" else -1 + elif depth == 0 and tokens[i].lower() == '"launchoptions"' and i + 1 < end: + return vdf_string(tokens[i + 1]) + except (OSError, ValueError, IndexError, KeyError, TypeError, AttributeError, struct.error): + pass + return "" + + def shortcut(program, root): for appid, exe, start in shortcut_entries(root): if same_file(program, exe): @@ -372,7 +407,7 @@ def arguments(program, args): def main(argv): window = False - app, start, options = None, None, "" + app, start, options = None, None, None while argv and argv[0].startswith("--"): option = argv.pop(0) if option == "--window": @@ -397,6 +432,8 @@ def main(argv): say("usage: droiddeck-proton-run [--window] PROGRAM [ARGS...]") return 2 root = os.environ.get("STEAM_COMPAT_CLIENT_INSTALL_PATH") or STEAM_ROOT + if options is None: + options = steam_options(app, root) if app is not None else "" extra, args = split_options(options) if not argv: if int(app) >= STEAM_APP_LIMIT: diff --git a/tools/tests/test_desktop_open.py b/tools/tests/test_desktop_open.py index de98e75c6e..085b1a7479 100644 --- a/tools/tests/test_desktop_open.py +++ b/tools/tests/test_desktop_open.py @@ -568,6 +568,43 @@ class ProtonRunTest(Temp): self.assertTrue((self.root / "steamapps/compatdata/2733369024").is_dir()) self.assertEqual(dirs, [str(start)]) + def write_account(self): + self.write("Steam/config/loginusers.vdf", + '"users"\n{\n\t"76561198352563669"\n\t{\n\t\t"MostRecent"\t\t"1"\n\t}\n}\n') + return "Steam/userdata/392297941/config/" + + def test_without_steam_and_options_a_game_takes_its_steam_launch_options(self): + config = self.write_account() + self.write(config + "localconfig.vdf", '"UserLocalConfigStore"\n{\n\t"Software"\n\t{\n\t\t"Valve"\n\t\t{\n' + '\t\t\t"Steam"\n\t\t\t{\n\t\t\t\t"apps"\n\t\t\t\t{\n\t\t\t\t\t"413150"\n\t\t\t\t\t{\n' + '\t\t\t\t\t\t"cloud"\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\t"LaunchOptions"\t\t"-wrong"\n\t\t\t\t\t\t}\n' + '\t\t\t\t\t\t"LaunchOptions"\t\t"DXVK_HUD=1 %command% -d3d9 \\"-name=Two Words\\""\n' + '\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n}\n') + shortcuts = runpy.run_path(str(BIN / "droiddeck-steam-shortcuts")) + self.write(config + "shortcuts.vdf", shortcuts["write"]({"shortcuts": { + "0": {"appid": -1561598272, "AppName": "Batman", "LaunchOptions": "-d3d9"}, + "1": {"appid": -1, "AppName": "Other", "LaunchOptions": "-x"}, + }})) + root = str(self.root) + self.assertEqual(RUN["steam_options"]("413150", root), 'DXVK_HUD=1 %command% -d3d9 "-name=Two Words"') + self.assertEqual(RUN["steam_options"]("2733369024", root), "-d3d9") + self.assertEqual(RUN["steam_options"]("70", root), "") + self.assertEqual(RUN["steam_options"]("2733369025", root), "") + info = {"common": {"type": "Game"}, "config": {"launch": { + "0": {"executable": "Game.exe", "type": "default", "config": {"oslist": "windows"}}}}} + self.write("Steam/appcache/appinfo.vdf", appinfo({413150: info})) + program = self.game("413150", "Some Game", "Game.exe") + code, calls, _ = self.run_main(["--app", "413150"]) + self.assertIsNone(code) + _, argv, env = calls[0] + self.assertEqual(argv[1:], ["waitforexitandrun", str(program), "-d3d9", "-name=Two Words"]) + self.assertEqual(env["DXVK_HUD"], "1") + bat = self.write("Games/GOG/Batman/Batman.exe", b"MZ") + code, calls, _ = self.run_main(["--app", "2733369024", "--", str(bat)]) + self.assertEqual(calls[0][1][1:], ["waitforexitandrun", str(bat), "-d3d9"]) + code, calls, _ = self.run_main(["--app", "2733369024", "--options", "", "--", str(bat)]) + self.assertEqual(calls[0][1][1:], ["waitforexitandrun", str(bat)]) + def test_launch_options_split_like_steam_does(self): split = RUN["split_options"] self.assertEqual(split(""), ({}, []))