fix(desktop): run a store game's exe through its launcher so the EA environment and Origin process are set up (#2486)

* fix(desktop): run a store game's exe through its launcher so the EA environment and Origin process are set up

* fix(desktop): keep a store game's prefix and resolve its launcher through symlinks and deep folders

* fix(desktop): keep the exe's resolved compatdata folder when running its launcher and find the sidecar beside a symlinked exe
This commit is contained in:
Kurt Himebauch authored and GitHub committed 2026-11-11 20:55:37 -05:00
1 parent 2953739f1e
commit 8961d088f2
5 files changed
+130 -7

No files matched your search

@@ -17,6 +17,7 @@ PROTON_RUN = os.path.join(BIN, "droiddeck-proton-run")
APPIMAGE_RUN = os.path.join(BIN, "droiddeck-appimage-run")
SCRIPT_RUN = os.path.join(BIN, "droiddeck-script-run")
STEAM_LAUNCH = os.path.join(BIN, "droiddeck-steam-launch")
STORE_LAUNCH = os.path.join(BIN, "droiddeck-store-launch")
PROGRAMS = os.path.join(BIN, "droiddeck-desktop-programs")
CACHE = os.path.join(HOME, ".cache", "droiddeck")
IMPORTS = {"appimage": ("/opt/appimages/user", "app"), "folder": ("/opt/droiddeck-apps", "entry")}
@@ -272,12 +273,32 @@ def steam_title(path):
return None
def exe_prefix(path):
try:
run = runpy.run_path(PROTON_RUN)
root = os.environ.get("STEAM_COMPAT_CLIENT_INSTALL_PATH") or run["STEAM_ROOT"]
target = run["locate"](path, root)
return ["--prefix", target.appid, "--compatdata", target.compatdata]
except (OSError, ValueError, KeyError, IndexError):
return None
def store_launcher(path):
try:
return runpy.run_path(STORE_LAUNCH)["store_launcher"](path)
except (OSError, ValueError, KeyError):
return None
def command(path, args, what, window=False, appid=None):
folder = os.path.dirname(path)
if what == "steam":
return [STEAM_LAUNCH, "desktop", appid], folder
if what == "windows":
return [PROTON_RUN] + (["--window"] if window else []) + [path] + args, folder
launcher = None if args else store_launcher(path)
prefix = exe_prefix(path) if launcher else None
keep = prefix or []
return [PROTON_RUN] + (["--window"] if window else []) + keep + [launcher or path] + args, folder
if what == "x86 script":
return [FEX, "run", "--mode", "on", "--for", folder, "--"] + interpreter(path) + [path] + args, folder
if what == "script":
@@ -315,8 +315,8 @@ def locate(program, root):
os.path.dirname(program), root, "own")
def fixed(program, root, appid):
return Target(appid, os.path.join(root, "steamapps", "compatdata", str(appid)),
def fixed(program, root, appid, compatdata=None):
return Target(appid, compatdata or os.path.join(root, "steamapps", "compatdata", str(appid)),
os.path.dirname(program), root, "fixed")
@@ -451,6 +451,7 @@ def arguments(program, args, desktop=None, compatdata=None):
def main(argv):
window = False
prefix = None
compatdata = None
verb = VERB
game_id = None
desktop = None
@@ -461,6 +462,8 @@ def main(argv):
window = True
elif option == "--prefix" and argv and prefix_id(argv[0]):
prefix = argv.pop(0)
elif option == "--compatdata" and argv and os.path.isabs(argv[0]):
compatdata = argv.pop(0)
elif option == "--verb" and argv and argv[0] in VERBS:
verb = argv.pop(0)
elif option == "--game-id" and argv and argv[0].isdigit() and argv[0] != "0":
@@ -484,7 +487,7 @@ def main(argv):
say("%s is not an app id" % app)
return 2
if not argv and app is None:
say("usage: droiddeck-proton-run [--window] [--prefix ID] [--verb run] [--game-id ID] [--desktop WxH] PROGRAM [ARGS...]")
say("usage: droiddeck-proton-run [--window] [--prefix ID [--compatdata DIR]] [--verb run] [--game-id ID] [--desktop WxH] PROGRAM [ARGS...]")
return 2
root = os.environ.get("STEAM_COMPAT_CLIENT_INSTALL_PATH") or STEAM_ROOT
if options is None:
@@ -509,7 +512,7 @@ def main(argv):
if app is not None and int(app) >= STEAM_APP_LIMIT:
target = shortcut_target(app, program, start, root)
elif prefix:
target = fixed(program, root, prefix)
target = fixed(program, root, prefix, compatdata)
else:
target = locate(program, root)
available = tools(root)
@@ -48,14 +48,14 @@ def sidecar_at(folder):
return sidecar
def find_store_game(argv):
def find_store_game(argv, depth=MAX_DEPTH):
for raw in argv:
arg = raw.strip().strip('"').strip("'").replace("\\", "/")
low = arg.lower()
if not (low.endswith(LAUNCHER) or low.endswith(".exe") or low.endswith(".bat")) or "/" not in arg:
continue
folder = Path(arg).parent
for _ in range(MAX_DEPTH):
for _ in range(depth):
sidecar = sidecar_at(folder)
if sidecar is not None:
return folder, sidecar
@@ -65,6 +65,21 @@ def find_store_game(argv):
return None
def store_launcher(path):
real = os.path.realpath(path)
for start in dict.fromkeys([os.path.abspath(path), real]):
found = find_store_game([start], depth=len(Path(start).parts))
if found is None:
continue
folder, sidecar = found
launcher, exe = str(sidecar.get("launcher") or ""), str(sidecar.get("exe") or "")
if not launcher or not exe or (folder / launcher).is_symlink() or not (folder / launcher).is_file():
continue
if os.path.realpath(folder / exe).lower() == real.lower():
return str(folder / launcher)
return None
def drop_stale(folder, now=None):
code = folder / EPIC_CODE
try:
+38
View File
@@ -136,6 +136,30 @@ class CommandTest(Temp):
self.assertEqual(OPEN["command"](script, [], "x86 script")[0],
[OPEN["FEX"], "run", "--mode", "on", "--for", str(self.tmp), "--", "/bin/sh", script])
def test_a_store_games_exe_runs_through_its_launcher(self):
exe, launcher = str(self.tmp / "game.exe"), str(self.tmp / "launch.bat")
with mock.patch.dict(OPEN, {"store_launcher": lambda path: launcher if path == exe else None,
"exe_prefix": lambda path: ["--prefix", "4242", "--compatdata", "/c/4242"]}):
keep = ["--prefix", "4242", "--compatdata", "/c/4242"]
self.assertEqual(OPEN["command"](exe, [], "windows")[0], [OPEN["PROTON_RUN"]] + keep + [launcher])
self.assertEqual(OPEN["command"](exe, [], "windows", True)[0],
[OPEN["PROTON_RUN"], "--window"] + keep + [launcher])
self.assertEqual(OPEN["command"](exe, ["-x"], "windows")[0], [OPEN["PROTON_RUN"], exe, "-x"])
other = str(self.tmp / "other.exe")
self.assertEqual(OPEN["command"](other, [], "windows")[0], [OPEN["PROTON_RUN"], other])
def test_a_store_games_launcher_keeps_the_exes_prefix(self):
exe = self.tmp / "game.exe"
exe.write_text("x")
root = str(self.tmp / "steam")
with mock.patch.dict(os.environ, {"STEAM_COMPAT_CLIENT_INSTALL_PATH": root}), \
mock.patch.dict(OPEN, {"PROTON_RUN": str(BIN / "droiddeck-proton-run"),
"store_launcher": lambda path: str(self.tmp / "launch.bat")}):
command = OPEN["command"](str(exe), [], "windows")[0]
located = RUN["locate"](str(exe), root)
self.assertEqual(command[1:5], ["--prefix", located.appid, "--compatdata", located.compatdata])
self.assertEqual(str(RUN["own_id"](str(exe))), str(RUN["locate"](str(exe), root).appid))
def test_a_native_program_on_noexec_storage_runs_from_a_copy(self):
program = self.write("storage/tool", elf(183))
x86 = self.write("storage/game.x86_64", elf(62))
@@ -737,6 +761,20 @@ class ProtonRunTest(Temp):
self.assertEqual(env["STEAM_COMPAT_DATA_PATH"], str(signed))
self.assertFalse((self.root / "steamapps/compatdata/2733369024").exists())
def test_a_launcher_run_keeps_the_resolved_compatdata_folder(self):
bat = self.write("Games/Epic/Game/.droiddeck-launch.bat", b"@echo off")
signed = self.root / "steamapps/compatdata/-1561598272"
signed.mkdir(parents=True)
other = self.tmp / "Library2/steamapps/compatdata/555"
other.mkdir(parents=True)
for compatdata, appid in ((signed, "2733369024"), (other, "555")):
with self.subTest(compatdata=str(compatdata)):
code, calls, dirs = self.run_main(["--prefix", appid, "--compatdata", str(compatdata), str(bat)])
self.assertIsNone(code)
self.assertEqual(calls[0][2]["STEAM_COMPAT_DATA_PATH"], str(compatdata))
code, calls, dirs = self.run_main(["--prefix", "555", str(bat)])
self.assertEqual(calls[0][2]["STEAM_COMPAT_DATA_PATH"], str(self.root / "steamapps/compatdata/555"))
def test_prefix_folder_prefers_initialized_unsigned_over_empty_signed(self):
signed = self.root / "steamapps/compatdata/-1561598272"
signed.mkdir(parents=True)
+46
View File
@@ -35,6 +35,52 @@ class EaHook(unittest.TestCase):
self.assertIn((r'HKEY_LOCAL_MACHINE\SOFTWARE\EA Games\Game', 'DisplayName', 'Mass Effect 3'), entries)
self.assertIn((r'HKEY_LOCAL_MACHINE\SOFTWARE\Respawn\Titanfall2', 'DisplayName', 'Mass Effect 3'), entries)
def test_the_games_exe_maps_to_its_launcher_only(self):
with tempfile.TemporaryDirectory() as tmp:
folder = Path(tmp) / 'Game'
(folder / 'bin').mkdir(parents=True)
for name in ('bin/Game.exe', 'bin/Other.exe', store.LAUNCHER):
(folder / name).write_text('x')
sidecar = {'store': 'ea', 'id': 'Origin.OFR.50.1', 'exe': 'bin/Game.exe', 'launcher': store.LAUNCHER}
(folder / store.SIDECAR).write_text(json.dumps(sidecar))
self.assertEqual(store.store_launcher(str(folder / 'bin/Game.exe')), str(folder / store.LAUNCHER))
self.assertEqual(store.store_launcher(str(folder / 'bin/game.exe')), str(folder / store.LAUNCHER))
self.assertIsNone(store.store_launcher(str(folder / 'bin/Other.exe')))
self.assertIsNone(store.store_launcher(str(Path(tmp) / 'Elsewhere.exe')))
(folder / store.SIDECAR).write_text(json.dumps(dict(sidecar, launcher='')))
self.assertIsNone(store.store_launcher(str(folder / 'bin/Game.exe')))
def test_a_symlinked_or_deep_exe_still_finds_its_launcher(self):
with tempfile.TemporaryDirectory() as tmp:
folder = Path(tmp) / 'Game'
deep = folder / 'a/b/c/d/e/f'
deep.mkdir(parents=True)
(deep / 'Game.exe').write_text('x')
(folder / store.LAUNCHER).write_text('x')
sidecar = {'store': 'ea', 'id': 'Origin.OFR.50.1', 'exe': 'a/b/c/d/e/f/Game.exe', 'launcher': store.LAUNCHER}
(folder / store.SIDECAR).write_text(json.dumps(sidecar))
link = Path(tmp) / 'x/y/z/Link.exe'
link.parent.mkdir(parents=True)
link.symlink_to(deep / 'Game.exe')
expected = str(folder.resolve() / store.LAUNCHER)
self.assertEqual(store.store_launcher(str(deep / 'Game.exe')), expected)
self.assertEqual(store.store_launcher(str(link)), expected)
self.assertIsNone(store.find_store_game([str(deep / 'Game.exe')]))
def test_a_symlinked_exe_finds_the_sidecar_beside_the_link(self):
with tempfile.TemporaryDirectory() as tmp:
outside = Path(tmp) / 'Real/Game.exe'
outside.parent.mkdir()
outside.write_text('x')
folder = Path(tmp) / 'Game'
folder.mkdir()
(folder / store.LAUNCHER).write_text('x')
(folder / 'Game.exe').symlink_to(outside)
sidecar = {'store': 'ea', 'id': 'Origin.OFR.50.1', 'exe': 'Game.exe', 'launcher': store.LAUNCHER}
(folder / store.SIDECAR).write_text(json.dumps(sidecar))
self.assertEqual(store.store_launcher(str(folder / 'Game.exe')), str(folder / store.LAUNCHER))
self.assertIsNone(store.store_launcher(str(outside)))
def test_legacy_games_are_registered_by_content_id(self):
sidecar = {'id': 'Origin.OFR.50.0005237', 'title': 'Mass Effect 3 (2012)',
'extra': {'contentIds': '71073,71183, bad id', 'displayName': 'Mass Effect 3', 'locale': 'fr_FR'}}