feat: Epic Games Launcher for Linux (#928)

* feat: Epic Games Launcher for Linux

Install Epic's official Linux launcher (EGLv2) from Epic's CDN with Valve's
Steam Runtime 4 and run it under FEX, signed in with the linked Epic account.
Epic games launch through a hidden launcher instance so they get the
launcher's own arguments, with the exchange-code launch as the fallback, and
DroidDeck installs show up in the launcher as installed.

In the launcher, touch scrolls like a phone app and the gamepad drives the UI:
D-pad and left stick move the selection, A opens, B goes back, the right stick
and triggers scroll proportionally, X opens the options menu, Y the keyboard
and LB/RB switch tabs.

* feat: Epic Games Launcher for Linux

Install Epic's official Linux launcher (EGLv2) from Epic's CDN with Valve's
Steam Runtime 4 and run it under FEX, signed in with the linked Epic account.
Epic games launch through a hidden launcher instance so they get the
launcher's own arguments, with the exchange-code launch as the fallback, and
DroidDeck installs show up in the launcher as installed.

In the launcher, touch scrolls like a phone app and the gamepad drives the UI:
D-pad and left stick move the selection, A opens, B goes back, the right stick
and triggers scroll proportionally, X opens the options menu, Y the keyboard
and LB/RB switch tabs.

* Route Epic games through Steam, import launcher installs, offer the second library

- Every Epic launch goes Steam -> Epic Games Launcher -> game; Play inside the open launcher hands the game to Steam
- Games installed from inside the launcher get a Games-tab entry and launch through Steam; the launcher installs to the last Stores target
- Stores install picker offers the Steam second library, with side-by-side choices
- uruntime xattr-only failures no longer fail the launcher unpack (app-extract)

* Hand launcher Play and Steam links to Steam, wait for FEX on first run

Play on a game the launcher just installed is matched to its install
record and handed to Steam. Steam games listed in the launcher open
steam://rungameid links, which now start the game in a Steam session.
Opening the launcher before Steam has downloaded FEX asks Steam for it
and starts Steam instead of failing with no-fex.

* Address review: FEX check, play-in-Steam action, touch route thread, scroll scale

fexReady needs a FEX binary in Steam's FEX tool, not just its folder.
The play-in-Steam action stays until the link is handled, so Run Steam
at startup can't start a session first. The pad touch route reads the
mouse mode without side effects off the main thread and posts the pad
update there. Vertical scroll uses the output height. A status-2 unpack
counts only when AppRun is there. The xdg-open command is tested
end to end for Steam links.

* Open the launcher through Steam, recover dropped shortcuts, sign out of both

The Epic Games Launcher now runs as its own Steam shortcut, so opening
it starts Steam, which opens the launcher, and Play inside it goes to
the running Steam.

Steam dropped a running shortcut from its library when the game exited
after a sleep/wake replay or a server re-logon, and launching it then
waited forever at ShowInterstitials. login1 only replays sleep/wake
when Steam is asleep. The session restarts Steam when a requested
shortcut is missing, and when a game exits with its shortcut gone and
nothing else runs.

Resuming after a long pause no longer reports failure while traced
processes are still waking, so "Steam is paused" goes away on the first
tap.

Signing out of the launcher signs DroidDeck's Epic store out, and
signing out in DroidDeck restarts the launcher signed out and clears
the Epic web cookies.

* Address review: one session-switch poll, Epic setup can't block a session

A new switch confirmation replaces the pending poll instead of adding a
second one that could start the session again. Epic library sync and
install-folder setup at session start are each guarded, so a bad
preference no longer stops the guest from launching.

* Uninstall the Epic Games Launcher from the Games tab

An Uninstall button next to Launch asks first, closes a running
session, and removes the launcher and its runtime. The launcher's
sign-in and install records stay, so its games keep their Games-tab
entries and a reinstall comes back signed in. Its Steam shortcut goes
away on the next Steam start.

* Address review: uninstall only after the session has ended

The launcher's files are removed only once the session is not running
and its phase has ended; a shutdown still in progress after the wait
reports failure instead. The confirmation reads the session state from
the front-end state.

* Find FEX that Steam installed on the second library

Steam's tools on a second library live in DroidDeck's private copy,
which the session binds over the library. The launcher's FEX check
only looked on the shared storage, so with FEX there it always asked
Steam for FEX and only Steam opened. It now checks the private copy
too.

* Start games without Steam, per-game Settings menu with Wine sync

"Start without Steam" now really leaves the Steam client out: the game
runs in its own Proton/FEX through droiddeck-proton-run in a run
session, and the Epic Games Launcher opens on its own with its games
playing in it. Run sessions for these games are not pinned to the big
cores and get DirectAudio and the added-games list like Steam.

The Games tab card is now "Settings", titled "<game> Settings": Start
without Steam, FEX preset, Wine sync (ntsync, fsync, esync, wineserver
or the app default) and Default, which puts everything changed for the
game back to the app's settings. The app-wide Wine sync choice is shown
in the Steam settings Session tab.

* Address review: uninstall guard, routed games, shortcut matching

Opening or reinstalling the Epic Games Launcher waits while it is being
uninstalled. Added games that are Steam installs keep their Start
without Steam setting under their Steam app id and start as that Steam
game. Live shortcut lookups wait for Steam's library to load and match
a same-name shortcut by its executable, so no duplicate is added. The
session treats the open launcher as itself even when it could not tell
its Steam app id.

* Address review: drop a queued launcher switch when it is uninstalled

A confirmed switch to the Epic Games Launcher that is still waiting for
the old session to end is cancelled when the launcher is uninstalled,
and never starts while the uninstall runs. The launcher id test sets
its environment for its own runs only.
This commit is contained in:
MaxsTechReview authored and GitHub committed 2026-10-17 14:40:39 -04:00
1 parent 16f9916825
commit 2fe4d5303c
107 files changed
+8860 -371

No files matched your search

@@ -581,6 +581,31 @@ def wait_for_steam_shortcut_overview(agent_dir, game_id, timeout=45):
raise AgentError("STEAM_OVERVIEW_TIMEOUT", "Steam did not load shortcut app overview %d" % app_id)
def steam_shortcut_state(agent_dir, game_id, timeout=6):
if steam_shortcut_app_id(game_id) is None:
return "not-shortcut"
timeout = request_timeout({"timeout": timeout}, 6)
deadline = time.monotonic() + timeout
expression = """(() => {
const store = globalThis.appStore;
if (typeof store?.GetAppOverviewByGameID !== 'function' || !store.m_bIsInitialized) return 'loading';
if (store.GetAppOverviewByGameID(%s) != null) return 'ready';
return store.allApps.some(app => app.app_type == 1073741824) ? 'missing' : 'loading';
})()""" % json.dumps(game_id)
state = "loading"
while True:
try:
state = cdp_eval(agent_dir, expression, await_promise=False,
timeout=min(5, max(0.25, deadline - time.monotonic()))).get("value") or "loading"
except AgentError as error:
if error.code not in ("NO_DEVTOOLS", "DEVTOOLS_UNREACHABLE", "NO_TARGET", "TIMEOUT"):
raise
state = "loading"
if state == "ready" or time.monotonic() >= deadline:
return state
time.sleep(min(0.5, max(0, deadline - time.monotonic())))
def game_pids(app_id):
"""Our processes started for this Steam app (Steam sets SteamAppId / SteamGameId in their
environment, and Proton's wine processes inherit it)."""
@@ -858,6 +883,28 @@ def main(argv):
return 3
print("droiddeck-agent: Steam overview is ready for shortcut app %d" % prepared["appId"])
return 0
if argv and argv[0] == "--steam-asleep":
expression = """(() => {
const store = globalThis.SuspendResumeStore;
return store ? (store.m_bSuspending ? 'yes' : 'no') : 'unknown';
})()"""
try:
state = cdp_eval(Path(base) / "agent", expression, await_promise=False, timeout=3).get("value") or "unknown"
except (AgentError, OSError, ValueError):
state = "unknown"
print(state)
return {"yes": 0, "no": 5}.get(state, 1)
if argv and argv[0] == "--steam-shortcut-state":
if len(argv) not in (2, 3):
print("usage: droiddeck-agent --steam-shortcut-state <cgameid> [timeout-seconds]", file=sys.stderr)
return 2
try:
state = steam_shortcut_state(Path(base) / "agent", argv[1], argv[2] if len(argv) == 3 else 6)
except (AgentError, OSError, ValueError) as error:
print("droiddeck-agent: could not ask the client about the shortcut: %s" % error, file=sys.stderr)
return 1
print(state)
return {"ready": 0, "missing": 4, "not-shortcut": 3}.get(state, 1)
serve(Path(base) / "agent", focus="--no-focus" not in argv)
return 0
File diff suppressed because it is too large. Load diff
+4
View File
@@ -0,0 +1,4 @@
#!/bin/sh
[ -n "${LD_PRELOAD:-}" ] && export DROIDDECK_STEAM_PRELOAD="$LD_PRELOAD"
unset LD_PRELOAD LD_LIBRARY_PATH
exec /usr/bin/python3 -I /usr/local/bin/droiddeck-epic run
@@ -563,13 +563,32 @@ def want_fex():
write_if_changed(STATUS_FILE, json.dumps(status, indent=2) + "\n")
XATTR_ONLY_NOISE = re.compile(r"^(proot (error|warning)|Failed to exec memfd|Further error messages of this type are suppressed)")
def only_xattrs_failed(errors):
seen = False
for line in errors.splitlines():
if "write_xattr" in line:
seen = True
elif re.search(r"fail|could not|cannot|error", line, re.I) and not XATTR_ONLY_NOISE.match(line):
return False
return seen
def extract(image):
image = os.path.abspath(image)
clear_extracted()
x86 = elf_arch(image) in X86.values()
if os.access(URUNTIME, os.X_OK):
status = subprocess.call([URUNTIME, "--appimage-extract"], stdout=subprocess.DEVNULL,
env=dict(os.environ, TARGET_APPIMAGE=image))
run = subprocess.run([URUNTIME, "--appimage-extract"], stdout=subprocess.DEVNULL, stderr=subprocess.PIPE,
env=dict(os.environ, TARGET_APPIMAGE=image))
errors = run.stderr.decode("utf-8", "replace")
sys.stderr.write(errors)
status = run.returncode
if status == 2 and only_xattrs_failed(errors) and extracted() and os.path.lexists("squashfs-root/AppRun"):
say("uruntime could not keep the image's extended attributes; the files are unpacked")
status = 0
if status == 0 and extracted():
if x86:
want_fex()
@@ -586,7 +605,7 @@ def extract(image):
unsquashfs = shutil.which("unsquashfs")
if unsquashfs:
clear_extracted()
status = subprocess.call([unsquashfs, "-q", "-n", "-o", str(appimage_offset(image)), "-d", "squashfs-root", image],
status = subprocess.call([unsquashfs, "-q", "-n", "-no-xattrs", "-o", str(appimage_offset(image)), "-d", "squashfs-root", image],
stdout=subprocess.DEVNULL)
if status == 0:
if x86:
@@ -7,7 +7,7 @@ import subprocess
import sys
from pathlib import Path
SYNC_KEYS = ("BL_SYNC_FALLBACK", "BL_FSYNC_FIRST", "BL_SYNC_MIN_NOFILE", "PROTON_NO_ESYNC", "PROTON_NO_FSYNC", "PROTON_NO_NTSYNC", "WINEESYNC")
SYNC_KEYS = ("BL_SYNC", "BL_SYNC_FALLBACK", "BL_FSYNC_FIRST", "BL_SYNC_MIN_NOFILE", "PROTON_NO_ESYNC", "PROTON_NO_FSYNC", "PROTON_NO_NTSYNC", "WINEESYNC")
SEED_REDISTS = "/usr/local/bin/droiddeck-seed-redists"
PACK_KEYS = ("WINESERVER", "BL_SYNC_PACK", "WINEESYNC", "PROTON_NO_ESYNC", "PROTON_NO_FSYNC")
@@ -251,36 +251,6 @@ def force_ssbs(command, env):
return env
def umu_capable(proton):
"""Whether this Proton's script has umu's launch without Steam: GE-Proton, Proton-CachyOS and
DroidDeck-Proton run umu.exe in place of steam.exe when UMU_ID is set; Valve's Proton does not."""
try:
with open(proton, encoding="utf-8", errors="replace") as source:
text = source.read()
except OSError:
return False
return "UMU_ID" in text and "umu.exe" in text
def start_without_steam(command, env, app_id):
"""DROIDDECK_NO_STEAM=1 (a game's Start without Steam): launch the game without Proton's
steam.exe, for games that close right away because of what it sets up. A Proton with umu's
launch gets UMU_ID - Proton still sets up the prefix, and a Steam game keeps its protonfixes
under its own id; any other Proton runs the game straight in the prefix (runinprefix)."""
if env.get("DROIDDECK_NO_STEAM", "").lower() not in ("1", "on", "true", "yes"):
return command, env
if len(command) < 3 or command[1] != "waitforexitandrun":
return command, env
if umu_capable(command[0]):
if not env.get("UMU_ID"):
steam_game = app_id is not None and int(app_id) < 2**31
env = dict(env, UMU_ID=app_id if steam_game else "0")
print("droiddeck-game-env: starting without Steam (umu.exe in place of steam.exe, UMU_ID=%s)" % env["UMU_ID"], file=sys.stderr)
return command, env
print("droiddeck-game-env: starting without Steam (this Proton has no umu launch: runinprefix)", file=sys.stderr)
return [command[0], "runinprefix"] + command[2:], env
EVALUATOR_SCRIPT = re.compile(r"(?:^|[\\/])evaluatorscript_[0-9]+\.vdf$", re.IGNORECASE)
@@ -340,7 +310,6 @@ def main():
if mic_enabled == "0":
env["BANNER_AUDIO_DIRECT_MIC"] = "0"
env = force_ssbs(command, env)
command, env = start_without_steam(command, env, app_id)
sync = load_sync()
launch, launch_env = select_sync(command, env, sync)
if launch[0] != command[0]:
@@ -10,7 +10,9 @@ import importlib.util
import os
from pathlib import Path
import re
import subprocess
import sys
import threading
import uuid
import gi
@@ -24,6 +26,8 @@ INTERFACE = NAME + ".Manager"
UPOWER = "org.freedesktop.UPower"
UPOWER_ROOT = "/org/freedesktop/UPower"
NATIVE_PREPARE_MS = 1500
AGENT = Path(__file__).resolve().with_name("droiddeck-agent")
ASLEEP_WAIT = 6
INTROSPECTION = """
<node>
<interface name="org.freedesktop.login1.Manager">
@@ -80,6 +84,7 @@ class LoginManager:
if name == "CanSuspend":
reply.return_value(GLib.Variant("(s)", ("yes",)))
elif name in ("Suspend", "SuspendWithFlags"):
print("== login1: %s.%s asked by %s" % (interface.rsplit(".", 1)[-1], name, sender), flush=True)
if self.pending:
reply.return_dbus_error(NAME + ".OperationInProgress", "The session is already pausing")
return
@@ -149,7 +154,7 @@ class LoginManager:
if file.get_basename() == self.wake.name or (other and other.get_basename() == self.wake.name):
if self.wake.exists():
self.wake.unlink(missing_ok=True)
self.resume(force=True)
self.woken()
if file.get_basename() == self.state.name or (other and other.get_basename() == self.state.name):
self.check_state()
@@ -171,6 +176,19 @@ class LoginManager:
self.resume()
return False
def woken(self):
if self.pending is not None:
self.resume(force=True)
return
threading.Thread(target=lambda: GLib.idle_add(self.replay_unless_awake, steam_asleep()), daemon=True).start()
def replay_unless_awake(self, asleep):
if asleep is False and self.pending is None:
print("== login1: Steam is awake; no sleep/wake replay", flush=True)
return False
self.resume(force=True)
return False
def resume(self, force=False):
if self.pending is None:
if force:
@@ -195,6 +213,15 @@ class LoginManager:
self.notify(False)
def steam_asleep():
try:
code = subprocess.run([str(AGENT), "--steam-asleep"], stdin=subprocess.DEVNULL, stdout=subprocess.DEVNULL,
stderr=subprocess.DEVNULL, timeout=ASLEEP_WAIT).returncode
except (OSError, subprocess.SubprocessError):
return None
return {0: True, 5: False}.get(code)
def load_netmanager():
path = Path(__file__).resolve().with_name("droiddeck-netmanager")
loader = importlib.machinery.SourceFileLoader("droiddeck_netmanager", str(path))
@@ -2,6 +2,7 @@
"""Runs a Windows program with the Proton the Steam client has chosen for it.
droiddeck-proton-run [--window] PROGRAM [ARGS...]
droiddeck-proton-run --app ID [--dir FOLDER] [--options TEXT] [PROGRAM [ARGS...]]
The program belongs to an installed Steam game when it sits in one's folder, to a prefix when it
sits in one's drive_c, or to a non-Steam shortcut that names it; any other program gets a prefix of
@@ -10,11 +11,15 @@ config.vdf picks the tool, else the client's default for all other titles ("0").
started as the client starts it - its toolmanifest's command line, the waitforexitandrun verb and
the STEAM_COMPAT_* environment - so its wrapper applies the game's settings, components and audio.
--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).
"""
import json
import os
import re
import runpy
import shlex
import struct
import sys
import zlib
@@ -249,6 +254,81 @@ def locate(program, root):
os.path.dirname(program), root, "own")
def split_words(text):
try:
return shlex.split(text or "")
except ValueError:
return (text or "").split()
def split_options(text):
"""A shortcut's launch options: NAME=value words before %command% go to the environment, the words
after it - or all of them, without %command% - are the program's arguments."""
words = split_words(text)
if "%command%" not in words:
return {}, words
at = words.index("%command%")
env = {}
for word in words[:at]:
name, equals, value = word.partition("=")
if equals and re.fullmatch(r"[A-Za-z_][A-Za-z0-9_]*", name):
env[name] = value
return env, words[at + 1:]
def find_file(base, relative):
"""base/relative, matching each part without regard to case as Windows does."""
path = base
for part in [p for p in relative.replace("\\", "/").split("/") if p and p != "."]:
exact = os.path.join(path, part)
if part == ".." or os.path.exists(exact):
path = exact
continue
try:
match = next((name for name in sorted(os.listdir(path)) if name.lower() == part.lower()), None)
except OSError:
return None
if match is None:
return None
path = os.path.join(path, match)
return os.path.normpath(path)
def steam_install(appid, root):
for library in libraries(root):
found = re.search(r'"installdir"\s+"([^"]+)"',
read_text(os.path.join(library, "steamapps", "appmanifest_%s.acf" % appid)) or "")
if found:
return library, os.path.join(library, "steamapps", "common", found.group(1))
return None, None
def steam_launch(appid, root):
"""(target, program, arguments) for a Steam game's default Windows launch option, or None."""
library, install = steam_install(appid, root)
if not install or not os.path.isdir(install):
return None
entry = compat()["appinfo_entries"](os.path.join(root, "appcache", "appinfo.vdf")).get(str(appid), {})
options = [option for option in entry.get("launch_options", ())
if not option["betakey"] and (not option["oslist"] or "windows" in option["oslist"])]
options.sort(key=lambda option: (option["type"] not in ("", "default", "none"),
int(option["key"]) if option["key"].isdigit() else 0))
for option in options:
program = find_file(install, option["executable"])
if not program or not os.path.isfile(program):
continue
start = find_file(install, option["workingdir"]) if option["workingdir"] else None
target = Target(appid, os.path.join(library, "steamapps", "compatdata", str(appid)), install, library, "steam",
start if start and os.path.isdir(start) else os.path.dirname(program))
return target, program, split_words(option["arguments"])
return None
def shortcut_target(appid, program, start, root):
return Target(appid, os.path.join(root, "steamapps", "compatdata", str(appid)), os.path.dirname(program), root,
"shortcut", start if start and os.path.isdir(start) else None)
def steam_launches(target, program, root):
"""Whether a launch option of the Steam game starts [program]: then Steam should start it."""
if target.kind != "steam":
@@ -292,24 +372,52 @@ def arguments(program, args):
def main(argv):
window = False
app, start, options = None, None, ""
while argv and argv[0].startswith("--"):
option = argv.pop(0)
if option == "--window":
window = True
elif option in ("--app", "--dir", "--options") and argv:
value = argv.pop(0)
if option == "--app":
app = value
elif option == "--dir":
start = value
else:
options = value
elif option == "--":
break
else:
say("unknown option %s" % option)
return 2
if not argv:
if app is not None and not (app.isdigit() and 0 < int(app) < 2 ** 32):
say("%s is not an app id" % app)
return 2
if not argv and app is None:
say("usage: droiddeck-proton-run [--window] PROGRAM [ARGS...]")
return 2
program = os.path.abspath(argv[0])
if not os.path.isfile(program):
say("%s does not exist" % program)
return 2
root = os.environ.get("STEAM_COMPAT_CLIENT_INSTALL_PATH") or STEAM_ROOT
target = locate(program, root)
extra, args = split_options(options)
if not argv:
if int(app) >= STEAM_APP_LIMIT:
say("shortcut %s needs its program" % app)
return 2
found = steam_launch(app, root)
if found is None:
say("Steam game %s is not installed, or has no Windows launch option" % app)
return 2
target, program, own = found
args = own + args
else:
program = os.path.abspath(argv[0])
if not os.path.isfile(program):
say("%s does not exist" % program)
return 2
args = args + argv[1:]
if app is not None and int(app) >= STEAM_APP_LIMIT:
target = shortcut_target(app, program, start, root)
else:
target = locate(program, root)
available = tools(root)
name, why = choose_tool(target.appid, mapping(root), available)
if name is None:
@@ -318,13 +426,15 @@ def main(argv):
folder, command = available[name]
os.makedirs(target.compatdata, exist_ok=True)
env = environment(os.environ, target, folder, root, window)
say("%s with %s (%s), %s prefix %s" % (program, name, why, target.kind, target.compatdata))
env.update(extra)
say("%s with %s (%s), %s prefix %s%s" % (program, name, why, target.kind, target.compatdata,
", without the Steam client" if app is not None else ""))
try:
os.chdir(target.start)
except OSError:
os.chdir(os.path.dirname(program))
entry = os.path.join(folder, command)
os.execve(entry, [entry, VERB] + arguments(program, argv[1:]), env)
os.execve(entry, [entry, VERB] + arguments(program, args), env)
if __name__ == "__main__":
@@ -301,6 +301,24 @@ case $mode in
taskset -cp "$cores" $$ >/dev/null 2>&1 || true
fi
python3 /usr/local/bin/droiddeck-pad-defaults 2>&1 || true
run_program() {
local rc=0 child sig forwarded=0
{ trap - INT QUIT; exec "$@"; } <&0 &
child=$!
for sig in TERM HUP INT; do
trap "kill -$sig $child 2>/dev/null; forwarded=1" "$sig"
done
while :; do
forwarded=0
rc=0
wait "$child" || rc=$?
[ "$forwarded" = 1 ] || break
done
if [ -n "${BL_LAUNCH_DIR:-}" ]; then
printf '%s\n' "$rc" > "$BL_LAUNCH_DIR/run-status.tmp" && mv -f "$BL_LAUNCH_DIR/run-status.tmp" "$BL_LAUNCH_DIR/run-status"
fi
exit "$rc"
}
fex=()
if [ -x /usr/local/bin/droiddeck-fex ]; then
case $(od -An -tu2 -j18 -N2 "$target" 2>/dev/null | tr -d ' ') in
@@ -311,17 +329,17 @@ case $mode in
*.appimage)
export APPIMAGE_EXTRACT_AND_RUN=1
chmod +x "$target" 2>/dev/null
exec "${fex[@]}" "$target" "$@"
run_program "${fex[@]}" "$target" "$@"
;;
*.sh)
if [ -x /usr/local/bin/droiddeck-fex ]; then
exec /usr/local/bin/droiddeck-fex run --for "$target" -- bash "$target" "$@"
run_program /usr/local/bin/droiddeck-fex run --for "$target" -- bash "$target" "$@"
fi
exec bash "$target" "$@"
run_program bash "$target" "$@"
;;
*)
chmod +x "$target" 2>/dev/null
cd "$(dirname "$target")" && exec "${fex[@]}" "$target" "$@"
cd "$(dirname "$target")" && run_program "${fex[@]}" "$target" "$@"
;;
esac
;;
@@ -495,6 +513,9 @@ case $mode in
if [ "$pv" != "$app" ]; then
app=$pv
echo "== focused app: $app (touch mode ${tmode:-unset}) at $(date +%T)"
if [ -n "${BL_LAUNCH_DIR:-}" ]; then
printf '%s\n' "$app" > "$BL_LAUNCH_DIR/steam-focused-app.tmp" && mv -f "$BL_LAUNCH_DIR/steam-focused-app.tmp" "$BL_LAUNCH_DIR/steam-focused-app"
fi
fi
[ "$restore" = 1 ] || continue
case $pv in ''|*[!0-9]*) prev=; continue ;; esac
@@ -514,6 +535,44 @@ case $mode in
esac
done < <(xprop -spy -root "${atoms[@]}" 2>/dev/null)
) &
steam_hold_launch() {
_bl_launch_ready=
_bl_end=$((SECONDS + 120))
until [ "$(xprop -root GAMESCOPE_FOCUSED_APP 2>/dev/null | sed -n 's/.*= *//p')" = 769 ] || [ "$SECONDS" -ge "$_bl_end" ]; do
sleep 1
done
# With a large library the overview can stay missing for 30+ minutes while Steam already takes the launch URL.
_bl_overview_status=1
_bl_overview_tries=0
while [ "$_bl_overview_tries" -lt 2 ]; do
if /usr/local/bin/droiddeck-agent --wait-steam-shortcut-overview "$1" 45; then
_bl_overview_status=0
else
_bl_overview_status=$?
fi
if [ "$_bl_overview_status" -ne 1 ]; then
break
fi
_bl_overview_tries=$((_bl_overview_tries + 1))
echo "== steam: shortcut overview not ready yet (attempt $_bl_overview_tries of 2)"
sleep 2
done
if [ "$_bl_overview_status" -eq 0 ]; then
echo "== steam: shortcut overview ready; launching the requested game $1"
_bl_launch_ready=1
elif [ "$_bl_overview_status" -eq 3 ]; then
echo "== steam: not a shortcut CGameID; keeping the existing launch path"
sleep 4
_bl_launch_ready=1
else
echo "== steam: shortcut overview not ready after about 90 s; launching the requested game anyway $1"
_bl_launch_ready=1
fi
if [ "$_bl_launch_ready" = 1 ]; then
echo "== steam: interface up; launching the requested game $1"
printf '%s\n' "$1" > "$BL_LAUNCH_DIR/steam-game.tmp" && mv -f "$BL_LAUNCH_DIR/steam-game.tmp" "$BL_LAUNCH_DIR/steam-game"
fi
}
if [ -n "${BL_LAUNCH_DIR:-}" ] && [ -z "${BL_DESKTOP:-}" ]; then
_bl_held=
_bl_uninstall=
@@ -539,44 +598,7 @@ case $mode in
fi
if [ -n "$_bl_held" ]; then
set -- "${_bl_rest[@]}"
(
_bl_launch_ready=
_bl_end=$((SECONDS + 120))
until [ "$(xprop -root GAMESCOPE_FOCUSED_APP 2>/dev/null | sed -n 's/.*= *//p')" = 769 ] || [ "$SECONDS" -ge "$_bl_end" ]; do
sleep 1
done
# With a large library the overview can stay missing for 30+ minutes while Steam already takes the launch URL.
_bl_overview_status=1
_bl_overview_tries=0
while [ "$_bl_overview_tries" -lt 2 ]; do
if /usr/local/bin/droiddeck-agent --wait-steam-shortcut-overview "$_bl_held" 45; then
_bl_overview_status=0
else
_bl_overview_status=$?
fi
if [ "$_bl_overview_status" -ne 1 ]; then
break
fi
_bl_overview_tries=$((_bl_overview_tries + 1))
echo "== steam: shortcut overview not ready yet (attempt $_bl_overview_tries of 2)"
sleep 2
done
if [ "$_bl_overview_status" -eq 0 ]; then
echo "== steam: shortcut overview ready; launching the requested game $_bl_held"
_bl_launch_ready=1
elif [ "$_bl_overview_status" -eq 3 ]; then
echo "== steam: not a shortcut CGameID; keeping the existing launch path"
sleep 4
_bl_launch_ready=1
else
echo "== steam: shortcut overview not ready after about 90 s; launching the requested game anyway $_bl_held"
_bl_launch_ready=1
fi
if [ "$_bl_launch_ready" = 1 ]; then
echo "== steam: interface up; launching the requested game $_bl_held"
printf '%s\n' "$_bl_held" > "$BL_LAUNCH_DIR/steam-game.tmp" && mv -f "$BL_LAUNCH_DIR/steam-game.tmp" "$BL_LAUNCH_DIR/steam-game"
fi
) &
steam_hold_launch "$_bl_held" &
fi
fi
if [ -s "$HOME/.bl-autolaunch" ]; then
@@ -727,6 +749,81 @@ BUSCONF
echo "== steam args: ${_bl_ui[*]} ${_bl_cdp[*]} ${_bl_lang[*]} -clientbeta $steam_channel -no-cef-sandbox -cef-ozone-platform=x11 ${_bl_cef[*]} $*"
steam_updates=0
rm -f "$HOME/.bl-stop-requested" "$STEAMOS_STEAM_SHUTDOWN_SENTINEL" "$STEAMOS_STEAM_REBOOT_SENTINEL"
steam_other_game_running() {
local line value n open
open=$(cat "$BL_LAUNCH_DIR/epic-open" 2>/dev/null)
case $open in ?|*[!0-9]*) open=${BL_EPIC_APP_ID:-$open} ;; esac
line=$(xprop -root GAMESCOPE_FOCUSABLE_APPS 2>/dev/null) || return 1
case $line in *=*) value=${line#*= } ;; *) return 1 ;; esac
for n in ${value//,/ }; do
[ "$n" = 769 ] || [ "$n" = "$open" ] || return 0
done
return 1
}
steam_restart_for() {
if [ "$(cat "$HOME/.bl-restarted-for" 2>/dev/null)" = "$1" ]; then
echo "== steam: $2, but Steam was already restarted for it; launching it anyway"
return 1
fi
printf '%s\n' "$1" > "$HOME/.bl-restarted-for"
echo "== steam: $2; restarting Steam to launch it"
printf '%s\n' "$1" > "$HOME/.bl-restart-game"
"$steam_root/steamrtarm64/steam" -shutdown >/dev/null 2>&1
}
steam_launch_game() {
local state=0 tries
/usr/local/bin/droiddeck-agent --steam-shortcut-state "$1" 6 >/dev/null 2>&1 || state=$?
[ "$state" -eq 0 ] && rm -f "$HOME/.bl-restarted-for"
if [ "$state" -eq 4 ]; then
if steam_other_game_running; then
echo "== steam: the client lost shortcut $1, but a game is running; launching it anyway"
elif steam_restart_for "$1" "the client lost shortcut $1"; then
return
fi
fi
"$steam_root/steamrtarm64/steam" "steam://rungameid/$1" >/dev/null 2>&1
[ "$state" -eq 3 ] && return
for tries in 1 2 3 4 5 6 7 8; do
nap 1
state=0
/usr/local/bin/droiddeck-agent --steam-shortcut-state "$1" 1 >/dev/null 2>&1 || state=$?
[ "$state" -eq 4 ] || continue
if steam_other_game_running; then
echo "== steam: the client dropped shortcut $1 while launching it, but a game is running"
else
steam_restart_for "$1" "the client dropped shortcut $1 while launching it"
fi
return 0
done
}
steam_check_exits() {
local ran n state lost=
ran=$(pgrep -a -f 'SteamLaunch AppId=[0-9]' 2>/dev/null | sed -n 's/.* SteamLaunch AppId=\([0-9]*\).*/\1/p')
if [ -n "$ran" ]; then
for n in $ran; do
[ "$n" -ge 2147483648 ] && _bl_ran[$n]=1
done
_bl_exited=
return
fi
[ "${#_bl_ran[@]}" -gt 0 ] || return 0
if [ -z "$_bl_exited" ]; then
_bl_exited=1
return
fi
_bl_exited=
for n in "${!_bl_ran[@]}"; do
state=0
/usr/local/bin/droiddeck-agent --steam-shortcut-state "$(printf '%u' $(((n << 32) | 0x02000000)))" 3 >/dev/null 2>&1 || state=$?
[ "$state" -eq 4 ] && lost="$lost $n"
done
_bl_ran=()
[ -n "$lost" ] || return 0
pgrep -f 'SteamLaunch AppId=[0-9]' >/dev/null 2>&1 && return 0
echo "== steam: the client dropped shortcut(s)$lost when they exited; restarting Steam so it lists them again"
: > "$HOME/.bl-restart-lost"
"$steam_root/steamrtarm64/steam" -shutdown >/dev/null 2>&1
}
steam_bring_forward() {
local end=$((SECONDS + 600)) behind=0 line name value focused other n
while [ "$SECONDS" -lt "$end" ]; do
@@ -766,6 +863,8 @@ BUSCONF
rm -f "$lossless_asked"
[ "${BL_LOSSLESS_OWNED:-0}" != 1 ] && lossless_left=60
declare -A _bl_pinned=()
declare -A _bl_ran=()
_bl_exited=
compat_stamp=$HOME/.bl-compat-beat
seed_stamp=$HOME/.bl-seed-beat
rm -f "$compat_stamp" "$seed_stamp"
@@ -827,7 +926,7 @@ BUSCONF
[ "$game_id_length" -eq 20 ] && [[ "$game_id" < "18446744073709551616" ]];
}; then
echo "== steam: launching requested game $game_id in the running client"
"$steam_root/steamrtarm64/steam" "steam://rungameid/$game_id" >/dev/null 2>&1 &
steam_launch_game "$game_id" &
[ -n "${forward_pid:-}" ] && kill "$forward_pid" 2>/dev/null
steam_bring_forward &
forward_pid=$!
@@ -842,6 +941,7 @@ BUSCONF
tick=$((tick + 1))
[ "$((tick % 10))" -eq 0 ] || continue
beat=$((beat + 1))
steam_check_exits
if [ "$beat" -le 720 ] && [ -n "${BL_CLIENT_CPUS:-}" ]; then
for _d in /proc/[0-9]*; do
IFS= read -r -d '' _c < "$_d/cmdline" 2>/dev/null || continue
@@ -887,8 +987,9 @@ BUSCONF
done
) &
stop_watcher=$!
rm -f "$HOME/.bl-restart-game" "$HOME/.bl-restarted-for"
while :; do
rm -f "$HOME/.bl-restart-once"
rm -f "$HOME/.bl-restart-once" "$HOME/.bl-restart-lost"
if [ -f "$steam_beta" ] && [ "$(cat "$steam_beta" 2>/dev/null)" != "$steam_channel" ]; then
echo "== steam: client branch on disk was '$(cat "$steam_beta" 2>/dev/null)', set to '$steam_channel' to match -clientbeta"
echo "$steam_channel" > "$steam_beta"
@@ -939,6 +1040,25 @@ BUSCONF
set --
continue
fi
if [ -s "$HOME/.bl-restart-game" ]; then
_bl_again=$(cat "$HOME/.bl-restart-game" 2>/dev/null)
rm -f "$HOME/.bl-restart-game"
case $_bl_again in
''|0*|*[!0-9]*) ;;
*)
echo "== steam: starting the client again to launch $_bl_again"
set --
steam_hold_launch "$_bl_again" &
continue
;;
esac
fi
if [ -f "$HOME/.bl-restart-lost" ]; then
rm -f "$HOME/.bl-restart-lost"
echo "== steam: starting the client again so it lists every shortcut"
set --
continue
fi
if [ -f "$HOME/.bl-restart-once" ]; then
echo "== steam: restarting once so the new compatibility layer is in the client's lists"
set --
@@ -184,7 +184,7 @@ def unimported(steam_root, snapshot, candidates):
def watch(steam_root, listing):
games = [game for game in read_json(listing, []) if not store_game(game)]
games = [game for game in read_json(listing, []) if not store_game(game) and not game.get("native")]
if os.environ.get("BL_STEAM_OFFLINE") == "1" or not games:
return
candidates, sources = {}, {}
@@ -408,6 +408,9 @@ def route(steam_root, acct, games):
print(f"droiddeck-steam-games: store import not undone ({error})")
shortcuts.append(game)
continue
if game.get("native"):
shortcuts.append(game)
continue
folder = game.get("folder", "")
appid = candidates.get(folder, candidates.get(legacy_path(folder)))
stamp = source_stamp(game)
@@ -180,12 +180,14 @@ def merge(fresh, current, state, seen):
def reconcile(existing, wanted, seen, record):
games, away = record["games"], dict(record["away"])
kept, ours, placed = [], [], {}
claimed = {(unquoted(fresh["Exe"]), fresh["AppName"]) for fresh in wanted.values()}
for value in existing.values():
if not isinstance(value, dict):
continue
tags = value.get("tags")
if not isinstance(tags, dict) or TAG not in tags.values():
kept.append(value)
if (unquoted(value.get("Exe")), value.get("AppName")) not in claimed:
kept.append(value)
continue
appid = value.get("appid")
if not isinstance(appid, int) or appid in placed:
@@ -342,7 +344,7 @@ def main():
spec.loader.exec_module(compat)
cfg = os.path.join(steam_root, "config", "config.vdf")
if os.path.isfile(cfg) and (ours or routes):
compat.register_default(cfg, apps=[str(int(g["appid"]) & 0xFFFFFFFF) for g in games if g.get("exe")] + [str(appid) for appid in set(routes.values())],
compat.register_default(cfg, apps=[str(int(g["appid"]) & 0xFFFFFFFF) for g in games if g.get("exe") and not g.get("native")] + [str(appid) for appid in set(routes.values())],
protect=compat.adopt_extras(os.path.join(steam_root, "compatibilitytools.d")))
print("droiddeck-steam-shortcuts: mapped them to %s" % compat.TOOL)
except Exception as e:
@@ -6,8 +6,10 @@ whoever started it: the Games tab, a pinned shortcut, or the Steam client's own
looks for the store launcher DroidDeck wrote (.droiddeck-launch.bat) among the arguments; beside it
.droiddeck-store.json says which store and game it is.
For an Epic game the game needs a fresh exchange code to sign in, which only the app can mint. The
request goes through files under $BL_LAUNCH_DIR/stores (the session root, the same path on both
For an Epic game, once the Epic Games Launcher is installed (droiddeck-epic), the game is started
through it: the hidden launcher signs the game in and hands its arguments back in
.droiddeck-epic-args. Without the launcher, or when it cannot, the game needs a fresh exchange code
to sign in, which only the app can mint. The request goes through files under $BL_LAUNCH_DIR/stores (the session root, the same path on both
sides):
req/<id>.json {"op": "epic-code", "store": "epic", "id": "<app name>"} (tmp + rename)
@@ -38,6 +40,11 @@ from pathlib import Path
LAUNCHER = ".droiddeck-launch.bat"
SIDECAR = ".droiddeck-store.json"
EPIC_CODE = ".droiddeck-epic-code"
EPIC_ARGS = ".droiddeck-epic-args"
EPIC_CLIENT = "/usr/local/bin/droiddeck-epic"
EPIC_CLIENT_CURRENT = ".local/share/droiddeck-epic/current.json"
EPIC_HANDLED = "DROIDDECK_EPIC_HANDLED"
CLIENT_TIMEOUT = 150.0
TIMEOUT = 5.0
STALE_SECONDS = 300
SERVER_WAIT = 8.0
@@ -98,6 +105,30 @@ def drop_stale(folder, now=None):
return False
def client_wanted():
home = os.environ.get("HOME") or "/root"
return os.access(EPIC_CLIENT, os.X_OK) and os.path.isfile(os.path.join(home, EPIC_CLIENT_CURRENT))
def through_client(folder, sidecar, timeout=CLIENT_TIMEOUT):
extra = sidecar.get("extra") if isinstance(sidecar.get("extra"), dict) else {}
namespace, item = str(extra.get("namespace") or ""), str(extra.get("catalogItemId") or "")
if not namespace or not item:
return "no-catalog-ids"
command = [EPIC_CLIENT, "launch", "--app", str(sidecar.get("id")), "--namespace", namespace, "--item", item,
"--folder", str(folder), "--owner", str(os.getppid()), "--timeout", str(int(timeout))]
try:
run = subprocess.run(command, stdout=subprocess.PIPE, stdin=subprocess.DEVNULL, timeout=timeout + 30)
answer = json.loads(run.stdout.decode("utf-8", "replace").strip().splitlines()[-1])
except (OSError, ValueError, IndexError, subprocess.TimeoutExpired) as error:
return "error-" + type(error).__name__
if not isinstance(answer, dict):
return "no-answer"
if answer.get("ok") and (folder / EPIC_ARGS).is_file():
return "ok"
return str(answer.get("reason") or "failed")
def ask(channel, request, timeout=TIMEOUT):
"""Writes [request] under channel/req and waits for channel/resp; the answer, or None on timeout."""
req_dir, resp_dir = channel / "req", channel / "resp"
@@ -247,10 +278,16 @@ def cloud_on(sidecar):
return str(sidecar.get("store")) in CLOUD_STORES and sidecar.get("cloud", True) is not False
def exited(argv):
def exited(argv, code=0):
"""After the game: ask the app to upload what changed, without waiting for it."""
found = find_store_game(argv)
launch_dir = os.environ.get("BL_LAUNCH_DIR", "")
if found is not None and str(found[1].get("store")) == "epic" and os.environ.get(EPIC_HANDLED) != "1" \
and os.access(EPIC_CLIENT, os.X_OK):
try:
subprocess.run([EPIC_CLIENT, "exited", "--code", str(code)], stdin=subprocess.DEVNULL, stdout=subprocess.DEVNULL, timeout=10)
except (OSError, subprocess.TimeoutExpired):
pass
if found is None or not launch_dir or not cloud_on(found[1]):
return 0
store, game = str(found[1].get("store")), str(found[1].get("id"))
@@ -329,7 +366,14 @@ def prepare_gog(sidecar, compat_data, launch_dir):
def main(argv):
if argv and argv[0] == "--exited":
return exited(argv[1:])
rest, code = argv[1:], 0
if rest[:1] == ["--code"] and len(rest) > 1:
try:
code = int(rest[1])
except ValueError:
pass
rest = rest[2:]
return exited(rest, code)
found = find_store_game(argv)
if found is None:
return 0
@@ -341,9 +385,27 @@ def main(argv):
if store == "gog":
prepare_gog(sidecar, compat_data, launch_dir)
if store == "epic":
drop_stale(folder)
handled = os.environ.get(EPIC_HANDLED) == "1" and (folder / EPIC_ARGS).is_file()
if not handled:
drop_stale(folder)
try:
(folder / EPIC_ARGS).unlink()
except OSError:
pass
choice = options(sidecar)
if not (choice["eos"] and not choice["offline"]):
client = None
if handled:
client = "ok"
elif choice["eos"] and not choice["offline"] and client_wanted():
client = through_client(folder, sidecar)
log("epic launch id=%s client=%s" % (game, client))
if client == "ok":
try:
(folder / EPIC_CODE).unlink()
except OSError:
pass
log("epic launch id=%s through=client" % game)
elif not (choice["eos"] and not choice["offline"]):
try:
(folder / EPIC_CODE).unlink()
except OSError:
@@ -73,7 +73,7 @@ bl_run() {
if [ -n "${BL_STORE_EXIT:-}" ]; then
"$@"
rc=$?
/usr/local/bin/droiddeck-store-launch --exited "${BL_STORE_ARGS[@]}" || true
/usr/local/bin/droiddeck-store-launch --exited --code "$rc" "${BL_STORE_ARGS[@]}" || true
exit $rc
fi
exec "$@"
@@ -660,6 +660,26 @@ def launch_programs(config):
return found
def launch_options(config):
"""An app's launch options as Steam lists them: executable, arguments, working folder, type and oslist."""
launch = config.get("launch") if isinstance(config, dict) else None
found = []
for key, option in launch.items() if isinstance(launch, dict) else ():
if not isinstance(option, dict) or not option.get("executable"):
continue
settings = option.get("config") if isinstance(option.get("config"), dict) else {}
found.append({
"key": str(key),
"executable": str(option["executable"]),
"arguments": str(option.get("arguments", "")),
"workingdir": str(option.get("workingdir", "")),
"type": str(option.get("type", "")).lower(),
"oslist": str(settings.get("oslist", "")).lower(),
"betakey": str(settings.get("betakey", "")),
})
return found
def appinfo_entries(path):
import struct
try:
@@ -751,6 +771,7 @@ def appinfo_entries(path):
"type": str(common.get("type", "")).lower(),
"recommended": str(recommended),
"launch": launch_programs(info.get("config")),
"launch_options": launch_options(info.get("config")),
}
if app == STEAM_PLAY_MANIFESTS:
extended = info.get("extended", {})