From a7b7e22968480c0b57f9a0335ee30e27baa9b88d Mon Sep 17 00:00:00 2001 From: xXJSONDeruloXx Date: Thu, 10 Sep 2026 15:11:51 -0400 Subject: fix: canonicalize existing Flatpak targets --- src/utils/steamLaunchOptions.ts | 12 +++++++++++- tests/steamLaunchOptions.test.ts | 31 +++++++++++++++++++++++++++++++ 2 files changed, 42 insertions(+), 1 deletion(-) diff --git a/src/utils/steamLaunchOptions.ts b/src/utils/steamLaunchOptions.ts index ea97a10..0c24887 100644 --- a/src/utils/steamLaunchOptions.ts +++ b/src/utils/steamLaunchOptions.ts @@ -428,11 +428,21 @@ export function installWrapperIntegration( if (savedOriginal && savedOriginal !== managedOriginal) { throw new Error("Shortcut Target changed externally; refusing to replace it"); } + const canonicalTarget = flatpakTargetValue(wrapperPath, managedOriginal); + let targetChanged = false; + if (current.target !== canonicalTarget) { + current = await writeVerified( + appId, true, current.target, canonicalTarget, + (target) => writeTarget(appId, target), readTarget, + "Steam did not accept the canonical Flatpak shortcut Target", + ); + targetChanged = true; + } return { snapshot: current, originalExecutable: savedOriginal || managedOriginal, commandTokenAdded: false, - changed: launchOptionsChanged, + changed: launchOptionsChanged || targetChanged, }; } const currentOriginal = selectFlatpakExecutable(transport, current.target); diff --git a/tests/steamLaunchOptions.test.ts b/tests/steamLaunchOptions.test.ts index 0559330..cdf0cf2 100644 --- a/tests/steamLaunchOptions.test.ts +++ b/tests/steamLaunchOptions.test.ts @@ -192,6 +192,37 @@ test("wraps a split direct Flatpak target while preserving its launch arguments" } }); +test("canonicalizes an existing quoted direct Flatpak target", async () => { + const previousWindow = (globalThis as Record).window; + const previousSteamClient = (globalThis as Record).SteamClient; + let shortcutTarget = '"~/.lsfg" "/usr/bin/flatpak"'; + const targetWrites: string[] = []; + const apps = { + RegisterForAppDetails(_appId: number, callback: (details: SteamAppDetails) => void) { + callback({ strShortcutExe: shortcutTarget, strShortcutLaunchOptions: "" }); + return { unregister() {} }; + }, + SetShortcutExe(_appId: number, executable: string) { + targetWrites.push(executable); + shortcutTarget = executable; + }, + SetShortcutLaunchOptions() {}, + }; + (globalThis as Record).window = { setTimeout, clearTimeout }; + (globalThis as Record).SteamClient = { Apps: apps }; + try { + const installed = await installWrapperIntegration(47, true, wrapper, false, { kind: "flatpak" }); + assert.equal(installed.originalExecutable, "/usr/bin/flatpak"); + assert.equal(installed.snapshot.target, "~/.lsfg /usr/bin/flatpak"); + assert.deepEqual(targetWrites, ["~/.lsfg /usr/bin/flatpak"]); + } finally { + if (previousWindow === undefined) delete (globalThis as Record).window; + else (globalThis as Record).window = previousWindow; + if (previousSteamClient === undefined) delete (globalThis as Record).SteamClient; + else (globalThis as Record).SteamClient = previousSteamClient; + } +}); + test("uses shortcut launch options for a host shortcut without changing its Target", async () => { const previousWindow = (globalThis as Record).window; const previousSteamClient = (globalThis as Record).SteamClient; -- cgit v1.2.3