Merge branch 'main' into fix/steam-client-download

# Conflicts:
#	tools/linuxfs/overlay/usr/local/bin/droiddeck-steam-install
#	tools/tests/test_steam_install.py
This commit is contained in:
maxjivi05 committed 2026-10-23 20:23:44 -04:00
commit 2d9d4dbeb0
155 files changed
+6161 -993

No files matched your search

@@ -589,7 +589,8 @@ def guest_environment(fex, env):
result["FEX_THUNKHOSTLIBS"] = fex["host_thunks"]
result["FEX_THUNKGUESTLIBS"] = fex["guest_thunks"]
result["FEX_THUNKCONFIG"] = os.path.join(CONFIG_DIR, "ThunksConfig.json")
preload = [part for part in split_paths(result.get("LD_PRELOAD")) if os.path.exists(part) and not is_arm(part)]
preload = [part for part in split_paths(result.get("LD_PRELOAD"))
if "/" not in part or (os.path.exists(part) and not is_arm(part))]
library_path = [part for part in (result.get("LD_LIBRARY_PATH") or "").split(":")
if part and "arm64" not in part and "aarch64" not in part]
for name, parts in (("LD_PRELOAD", preload), ("LD_LIBRARY_PATH", library_path)):
@@ -671,15 +672,26 @@ def launch(command, env, mode, decide=None):
return os.execve(fex["bin"], [fex["bin"], program] + command[1:], guest)
def game_environment(env):
def game_environment(env, command):
try:
game_env = runpy.run_path(os.path.join(BIN_DIR, "droiddeck-game-env"))
env = game_env["game_gpu"](env)
app = game_env["game_id"](env) or env.get("SteamAppId") or env.get("SteamGameId")
if not app:
return env
with open(GAME_ENVIRONMENT, encoding="utf-8") as source:
return game_env["apply_config"](env, json.load(source), str(app))
fixes = {}
game = game_env["Game"](resolve(command[0], env), command[1:])
for check in game_env["FIXES"]:
found = check(game)
if found and found[0]:
fixes.update(found[0])
say(found[2])
try:
with open(GAME_ENVIRONMENT, encoding="utf-8") as source:
config = json.load(source)
except FileNotFoundError:
config = {"version": 1}
return game_env["apply_config"](env, config, str(app), fixes)
except FileNotFoundError:
return env
except Exception as error:
@@ -810,7 +822,7 @@ def main(argv):
return 0
if not command:
return 2
return launch(command, game_environment(dict(os.environ)), os.environ.get("DROIDDECK_FEX", "auto"))
return launch(command, game_environment(dict(os.environ), command), os.environ.get("DROIDDECK_FEX", "auto"))
if action == "run":
try:
mode, decide, command = parse_run(args)
@@ -87,6 +87,12 @@ def dotnet_memory_ordering(game):
return DOTNET_FEX, [], ".NET runtime: FEX with full TSO and without multiblock"
@fix
def unity_memory_ordering(game):
if {"unityplayer.so", "gameassembly.so", "unityplayer.dll"} & game.files:
return {"FEX_TSOENABLED": "1"}, [], "Unity: FEX with TSO"
@fix
def godot_vulkan(game):
if is_godot(game) and not game.has_arg("--rendering-driver"):
@@ -227,7 +227,9 @@ if [ -z "${BL_INSIDE:-}" ]; then
echo "== gamescope: games at ${nested}x${height} stretched to the ${width}x${height} output"
fi
fi
if [ "$mode" = steam ]; then
# Off unless Performance asks for it. Compositing the cursor here adds a second
# plane on the phone's compositor; a controller-driven cursor is the reason to turn it on.
if [ "$mode" = steam ] && [ "${BL_CURSOR_COMPOSITE:-0}" = 1 ]; then
export gamescope_cursor_composite=2
fi
args=(--backend wayland --expose-wayland -f -W "$width" -H "$height" -w "$nested" -h "$height")
@@ -405,6 +407,11 @@ case $mode in
droiddeck-steam-x64 --sync-login || true
fi
steam_client=("$steam_root/steamrtarm64/steam")
_bl_srt_shim=$HOME/.droiddeck-steamrt-shim
if droiddeck-steamrt-shim "$steam_root/steamrtarm64" "$_bl_srt_shim"; then
echo "== steam: Valve containerized the arm64 Steam client (it carries a Steam Runtime container); starting it through $_bl_srt_shim"
steam_client=(env STEAM_RUNTIME_STEAMRT="$_bl_srt_shim" PATH="$_bl_srt_shim/bin:$PATH" "${steam_client[@]}")
fi
fi
_bl_proton_root=$steam_root
if [ "$steam_x64" = 1 ]; then
@@ -528,6 +535,11 @@ case $mode in
fi
droiddeck-seed-redists "$steam_root" || true
fi
if [ -n "${BL_SHADER_PRECACHE:-}" ]; then
droiddeck-steam-shaders "$BL_SHADER_PRECACHE" "$XDG_DATA_HOME/Steam" \
"${BL_X64_HOME:-$HOME/.droiddeck-x64}/.local/share/Steam" &&
echo "$BL_SHADER_PRECACHE" > "$HOME/.bl-shader-precache-applied" || true
fi
if [ "$steam_x64" = 0 ] && [ ! -f "$steam_root/steamapps/appmanifest_4427310.acf" ]; then
step "asking the client to fetch the ARM64 Proton"
set -- "$@" steam://install/4427310
@@ -748,10 +760,13 @@ BUSCONF
fi
# The UI bridge launches SteamVR, which needs the guest agent's library environment.
_bl_compat_env=(env -u LD_LIBRARY_PATH -u STEAM_RUNTIME)
_bl_compat_env=(env -u LD_LIBRARY_PATH -u STEAM_RUNTIME -u STEAM_STEAMRT_RECURSION_GUARD)
[ "${LD_LIBRARY_PATH+x}" ] && _bl_compat_env+=("LD_LIBRARY_PATH=$LD_LIBRARY_PATH")
[ "${STEAM_RUNTIME+x}" ] && _bl_compat_env+=("STEAM_RUNTIME=$STEAM_RUNTIME")
[ "${STEAM_STEAMRT_RECURSION_GUARD+x}" ] && _bl_compat_env+=("STEAM_STEAMRT_RECURSION_GUARD=$STEAM_STEAMRT_RECURSION_GUARD")
export STEAM_RUNTIME=1
# A containerized client re-executes itself through pressure-vessel-wrap (bwrap) unless told it is already inside.
export STEAM_STEAMRT_RECURSION_GUARD=1
export LD_LIBRARY_PATH=$steam_root/steamrtarm64:$steam_root/steamrtarm64/panorama${LD_LIBRARY_PATH:+:$LD_LIBRARY_PATH}
export SDL_VIDEO_X11_DGAMOUSE=0
decky_loader=$HOME/homebrew/services/PluginLoader
@@ -831,6 +846,9 @@ BUSCONF
unset _stale _f
fi
steam_channel=steamdeck_publicbeta
if [ "$steam_x64" = 0 ]; then
steam_channel=$(droiddeck-steam-install --channel 2>/dev/null || echo steamdeck_publicbeta)
fi
_bl_lang=()
[ -n "${BL_STEAM_LANGUAGE:-}" ] && _bl_lang=(-language "$BL_STEAM_LANGUAGE")
steam_beta=$steam_root/package/beta
@@ -583,9 +583,8 @@ class Helper:
picked = COMPAT["picked_apps"](state)
runnable = {t["name"].lower() for t in live}
apps = sorted(set(installed) | set(picks) | set(prior_auto) | native_choices, key=COMPAT["app_order"])
overrides = COMPAT["requested_games"](
COMPAT["game_requests"](), catalog, [t["name"] for t in live])
apps = sorted(set(apps) | set(overrides), key=COMPAT["app_order"])
asked = [app for app, request in COMPAT["game_requests"]().items() if COMPAT["valid_game_request"](app, request)]
apps = sorted(set(apps) | set(asked), key=COMPAT["app_order"])
current = dict(page.compat("many(%s)" % json.dumps(apps)) or {})
refused = set(apps) - set(current)
refused_native = native_choices & refused
@@ -597,7 +596,6 @@ class Helper:
if isinstance(state.get("auto"), dict):
state["auto"] = prior_auto
native_choices -= refused
overrides = {app: tool for app, tool in overrides.items() if app not in refused}
current["0"] = top["selected"]
native = COMPAT["native_targets"](self.steam_root, apps)
raw_mapping = COMPAT["read_config_mapping"](
@@ -619,6 +617,9 @@ class Helper:
current[app] = ""
elif not current.get(app):
current.pop(app, None)
requests = COMPAT["settled_game_requests"](state, current, catalog)
overrides = COMPAT["requested_games"](requests or {}, catalog, [t["name"] for t in live])
overrides = {app: tool for app, tool in overrides.items() if app not in refused}
changes, auto = COMPAT["plan_mapping"](
current, installed, [t["name"] for t in live], default,
COMPAT["followers"](state, current), native, picks, overrides,
@@ -630,7 +631,8 @@ class Helper:
state.update(
auto={app: tool for app, tool in auto.items() if tool is not COMPAT["NATIVE_CHOICE"]},
native_choices=sorted(refused_native | {app for app, tool in auto.items() if tool is COMPAT["NATIVE_CHOICE"]}),
picked=COMPAT["picked_after"](current, changes), tools=catalog, live=True)
picked=COMPAT["picked_after"](current, changes), tools=catalog, live=True,
games_applied=COMPAT["applied_game_requests"](requests, overrides, state))
state.pop("native", None)
if waiting:
state["pending"] = wanted
@@ -1,9 +1,26 @@
#!/bin/bash
set -eu
cdn_list="https://client-update.steamstatic.com https://client-update.akamai.steamstatic.com https://client-update.fastly.steamstatic.com"
steam_channel=steamdeck_publicbeta
manifest=steam_client_${steam_channel}_linuxarm64
beta_channel=steamdeck_publicbeta
stable_channel=steamdeck_stable
steam_root=${XDG_DATA_HOME:-$HOME/.local/share}/Steam
channel_state=$steam_root/package/droiddeck-channel
pinned=1
wanted=${BL_STEAM_CHANNEL:-$(cat "$HOME/.config/droiddeck/steam-channel" 2>/dev/null || true)}
case $wanted in
stable|"$stable_channel") steam_channel=$stable_channel ;;
beta|"$beta_channel") steam_channel=$beta_channel ;;
*)
pinned=
steam_channel=$beta_channel
[ "$(cat "$channel_state" 2>/dev/null)" = "$stable_channel" ] && steam_channel=$stable_channel
;;
esac
if [ "${1:-}" = --channel ]; then
echo "$steam_channel"
exit 0
fi
manifest=steam_client_${steam_channel}_linuxarm64
stamp=$steam_root/package/droiddeck-installed
legacy_stamp=$steam_root/package/bannerlator-installed
unconfirmed=$steam_root/package/droiddeck-unconfirmed
@@ -15,11 +32,21 @@ if [ -f "$legacy_stamp" ] && [ ! -f "$stamp" ]; then
mv -f "$legacy_stamp" "$stamp" || true
fi
repair=""
fallback=""
starts=0
[ -f "$unconfirmed" ] && starts=$(grep -cx start "$unconfirmed" || true)
if [ -e "$repair_request" ]; then
repair="requested"
elif [ -f "$unconfirmed" ] && ! grep -qx repaired "$unconfirmed" \
&& [ "$(grep -cx start "$unconfirmed")" -ge 2 ]; then
repair="the client was started $(grep -cx start "$unconfirmed") times without showing anything"
elif [ "$starts" -ge 2 ] && ! grep -qx repaired "$unconfirmed"; then
repair="the client was started $starts times without showing anything"
elif [ "$starts" -ge 2 ] && [ -z "$pinned" ] && [ "$steam_channel" = "$beta_channel" ] && [ "${1:-}" != --sync ]; then
repair="the repaired $beta_channel client was started $starts more times without showing anything"
fallback=1
fi
if [ -n "$fallback" ]; then
echo "== STEP $(date -u +%H:%M:%S) falling back to Valve's $stable_channel Steam client: $repair"
steam_channel=$stable_channel
manifest=steam_client_${steam_channel}_linuxarm64
fi
if [ -n "$repair" ]; then
echo "== STEP $(date -u +%H:%M:%S) repairing the Steam client ($repair)"
@@ -113,20 +140,43 @@ fetch() {
done
}
cdn=""
for candidate in $cdn_list; do
if curl -fsSL --connect-timeout 10 --max-time 30 --retry 2 --retry-connrefused --retry-delay 3 \
"$candidate/$manifest" -o "$work/manifest"; then
cdn=$candidate
break
fetch_manifest() {
cdn=""
for candidate in $cdn_list; do
if curl -fsSL --connect-timeout 10 --max-time 30 --retry 2 --retry-connrefused --retry-delay 3 \
"$candidate/$manifest" -o "$work/manifest"; then
cdn=$candidate
break
fi
done
[ -n "$cdn" ] || { echo "droiddeck-steam-install: no Steam client CDN answered for $manifest" >&2; exit 1; }
cdn_order=("$cdn")
for candidate in $cdn_list; do
[ "$candidate" = "$cdn" ] || cdn_order+=("$candidate")
done
version=$(awk -F'"' '$2 == "version" { print $4; exit }' "$work/manifest")
awk -F'"' '
/^\t"/ && NF >= 3 && $4 == "" { block = $2 }
$2 == "file" { file[block] = $4 }
$2 == "sha2" { sha[block] = $4 }
$2 == "size" { size[block] = $4 }
END { for (b in file) if (b ~ /_all$/ || b ~ /_linuxarm64_linuxarm64$/) print b, file[b], sha[b], size[b] + 0 }
' "$work/manifest" | sort > "$work/parts"
[ -s "$work/parts" ] && return 0
echo "droiddeck-steam-install: no client components in $manifest; its blocks are:" \
"$(awk -F'"' '/^\t"/ && NF >= 3 && $4 == "" { printf "%s ", $2 }' "$work/manifest")" >&2
return 1
}
if ! fetch_manifest; then
if [ -n "$sync" ] || [ -n "$pinned" ] || [ "$steam_channel" = "$stable_channel" ]; then
exit 1
fi
done
[ -n "$cdn" ] || { echo "droiddeck-steam-install: no Steam client CDN answered for $manifest" >&2; exit 1; }
cdn_order=("$cdn")
for candidate in $cdn_list; do
[ "$candidate" = "$cdn" ] || cdn_order+=("$candidate")
done
version=$(awk -F'"' '$2 == "version" { print $4; exit }' "$work/manifest")
echo "== STEP $(date -u +%H:%M:%S) falling back to Valve's $stable_channel Steam client: $manifest has no arm64 client"
steam_channel=$stable_channel
manifest=steam_client_${steam_channel}_linuxarm64
fallback=1
fetch_manifest || exit 1
fi
if [ -n "$sync" ]; then
installed=$(awk -F'"' '$2 == "version" { print $4; exit }' "$steam_root/package/$manifest.manifest" 2>/dev/null || true)
if [ -x "$steam_root/steamrtarm64/steam" ] && [ "$installed" = "$version" ]; then
@@ -135,15 +185,6 @@ if [ -n "$sync" ]; then
fi
echo "== STEP $(date -u +%H:%M:%S) updating the arm64 Steam client to $version (was ${installed:-none}) for the x86-64 client"
fi
# Every component block: its name, then the plain zip's file name, sha256 and size.
awk -F'"' '
/^\t"/ && NF >= 3 && $4 == "" { block = $2 }
$2 == "file" { file[block] = $4 }
$2 == "sha2" { sha[block] = $4 }
$2 == "size" { size[block] = $4 }
END { for (b in file) if (b ~ /_all$/ || b ~ /_linuxarm64_linuxarm64$/) print b, file[b], sha[b], size[b] + 0 }
' "$work/manifest" | sort > "$work/parts"
[ -s "$work/parts" ] || { echo "droiddeck-steam-install: no client components in $manifest" >&2; exit 1; }
total=$(grep -c . "$work/parts" 2>/dev/null || echo 0)
total_bytes=$(awk '{ n += $4 } END { print n + 0 }' "$work/parts")
@@ -206,6 +247,10 @@ ln -sfn "$steam_root/steamrtarm64" "$HOME/.steam/binarm64"
ln -sfn "$steam_root/linux32" "$HOME/.steam/sdk32"
echo "$version" > "$stamp"
rm -rf "$parts"
if [ -n "$fallback" ]; then
echo "$stable_channel" > "$channel_state"
echo "== STEP $(date -u +%H:%M:%S) the Steam client now follows $stable_channel (beta in ~/.config/droiddeck/steam-channel returns to $beta_channel)"
fi
if [ -n "$repair" ]; then
echo repaired > "$unconfirmed"
rm -f "$repair_request"
@@ -0,0 +1,61 @@
#!/usr/bin/python3
"""Sets the Steam client's shader pre-caching (Settings > Downloads), before the client starts.
droiddeck-steam-shaders <0|1> <steam root>...
The client stores the toggle as InstallConfigStore/Software/Valve/Steam/ShaderCacheManager/
DisableShaderCache in config/config.vdf: "1" when off, "0" when on. It keeps the setting in memory
and writes config.vdf back on exit, so this runs only while the client is stopped. The launcher
passes a value only after its own toggle changes; otherwise the client's toggle stays the user's."""
from pathlib import Path
import runpy
import sys
VDF = runpy.run_path(str(Path(__file__).with_name("droiddeck-steam-ui-scale")))
PATH = ("Software", "Valve", "Steam", "ShaderCacheManager", "DisableShaderCache")
def set_text(text, enabled):
value = "0" if enabled else "1"
updated, changed = VDF["seed_value"](text, PATH, value)
if changed:
return updated, True
block = VDF["parse"](text).get("InstallConfigStore")
for section in PATH[:-1]:
block = block.get(section)
current = block.get(PATH[-1])
if isinstance(current, VDF["Block"]):
raise ValueError("invalid DisableShaderCache setting")
if current == value:
return text, False
at = block.offset(PATH[-1])
end = VDF["TOKEN"].match(text, at).end()
return text[:at] + f'"{value}"' + text[end:], True
def apply(steam_root, enabled):
config = Path(steam_root) / "config/config.vdf"
text = config.read_text() if config.exists() else '"InstallConfigStore"\n{\n}\n'
updated, changed = set_text(text, enabled)
if changed:
VDF["atomic_write"](config, updated)
return changed
if __name__ == "__main__":
if len(sys.argv) < 3 or sys.argv[1] not in ("0", "1"):
print("usage: droiddeck-steam-shaders <0|1> <steam root>...", file=sys.stderr)
sys.exit(2)
enabled = sys.argv[1] == "1"
status = 0
for root in sys.argv[2:]:
if not Path(root).is_dir():
continue
try:
if apply(root, enabled):
print(f"== steam: shader pre-caching {'on' if enabled else 'off'} in {root}")
except (OSError, ValueError, RecursionError) as error:
print(f"== steam: left shader pre-caching unchanged in {root}: {error}", file=sys.stderr)
status = 1
sys.exit(status)
@@ -26,9 +26,10 @@ TOKEN = re.compile(r'\s+|//[^\n]*|"(?:\\.|[^"\\])*"|[{}]')
class Block:
def __init__(self, pairs, end):
def __init__(self, pairs, end, offsets=()):
self.pairs = pairs
self.end = end
self.offsets = offsets
def get(self, name):
matches = [value for key, value in self.pairs if key.lower() == name.lower()]
@@ -36,6 +37,9 @@ class Block:
raise ValueError("duplicate UI setting")
return matches[0] if matches else None
def offset(self, name):
return next(at for (key, _), at in zip(self.pairs, self.offsets) if key.lower() == name.lower())
def parse(text):
tokens = []
@@ -51,17 +55,17 @@ def parse(text):
raise ValueError("invalid config.vdf")
def block(index, nested=False):
pairs = []
pairs, offsets = [], []
while index < len(tokens):
token, offset = tokens[index]
if token == '}':
if not nested:
raise ValueError("unexpected closing brace")
return Block(pairs, offset), index + 1
return Block(pairs, offset, offsets), index + 1
if not token.startswith('"') or index + 1 == len(tokens):
raise ValueError("missing config value")
key = token[1:-1]
value = tokens[index + 1][0]
value, at = tokens[index + 1]
index += 2
if value == '{':
value, index = block(index, True)
@@ -70,9 +74,10 @@ def parse(text):
else:
raise ValueError("invalid config value")
pairs.append((key, value))
offsets.append(at)
if nested:
raise ValueError("unclosed config block")
return Block(pairs, len(text)), index
return Block(pairs, len(text), offsets), index
return block(0)[0]
@@ -520,39 +520,8 @@ ln -sfn "$STEAM_X64/ubuntu12_32" "$X64_HOME/.steam/bin32"
ln -sfn "$STEAM_X64/ubuntu12_64" "$X64_HOME/.steam/bin64"
ln -sfn "$STEAM_X64/linux32" "$X64_HOME/.steam/sdk32"
ln -sfn "$STEAM_X64/linux64" "$X64_HOME/.steam/sdk64"
# The client's bwrap probe (steam-runtime-check-requirements) needs user namespaces, which no Android app has.
srt_real=$STEAM_X64/steamrt64/pv-runtime/steam-runtime-steamrt
srt_shim=$X64_HOME/steamrt-shim
if [ -d "$srt_real" ]; then
rm -rf "$srt_shim"
mkdir -p "$srt_shim/bin"
for e in "$srt_real"/* "$srt_real"/.[!.]*; do
[ -e "$e" ] || continue
[ "$(basename "$e")" = bin ] || ln -s "$e" "$srt_shim/$(basename "$e")"
done
for e in "$srt_real"/bin/*; do ln -s "$e" "$srt_shim/bin/$(basename "$e")"; done
rm -f "$srt_shim/bin/steam-runtime-check-requirements"
printf '#!/bin/sh
exit 0
' > "$srt_shim/bin/steam-runtime-check-requirements"
chmod 755 "$srt_shim/bin/steam-runtime-check-requirements"
rm -f "$srt_shim/bin/steam-runtime-launch-client"
cat > "$srt_shim/bin/steam-runtime-launch-client" <<'LAUNCH'
#!/bin/sh
while [ $# -gt 0 ]; do
case $1 in
--) shift; break ;;
--directory=*) cd "${1#--directory=}" || exit 127 ;;
--env=*) export "${1#--env=}" ;;
--unset-env=*) unset "${1#--unset-env=}" ;;
esac
shift
done
[ $# -gt 0 ] || exit 0
exec "$@"
LAUNCH
chmod 755 "$srt_shim/bin/steam-runtime-launch-client"
fi
# Valve's Steam Runtime container needs user namespaces and a session-bus launcher; steamrt-shim stands in for both.
droiddeck-steamrt-shim "$STEAM_X64/steamrt64" "$X64_HOME/steamrt-shim" || rm -rf "$X64_HOME/steamrt-shim"
# Valve's platform libraries ship without soname links (pressure-vessel makes them); ldconfig adds them here.
srt_libs=$X64_HOME/steamrt-libs
rm -rf "$srt_libs"
+58
View File
@@ -0,0 +1,58 @@
#!/bin/bash
# droiddeck-steamrt-shim <client runtime dir> <shim dir>
# Builds <shim dir> from the Steam Runtime container the client carries and exits 0, or removes it and exits 1
# when the client carries none.
set -eu
client=$1
shim=$2
srt_real=$client/pv-runtime/steam-runtime-steamrt
if [ ! -d "$srt_real" ]; then
probe=$(find "$client" -maxdepth 4 -name steam-runtime-check-requirements -path '*/bin/*' -print -quit 2>/dev/null || true)
srt_real=${probe:+${probe%/bin/*}}
fi
if [ -z "$srt_real" ] || [ ! -d "$srt_real" ]; then
rm -rf "$shim"
exit 1
fi
rm -rf "$shim"
trap 'rm -rf "$shim"' ERR
mkdir -p "$shim/bin"
for e in "$srt_real"/* "$srt_real"/.[!.]*; do
[ -e "$e" ] || continue
[ "$(basename "$e")" = bin ] || ln -s "$e" "$shim/$(basename "$e")"
done
for e in "$srt_real"/bin/*; do
[ -e "$e" ] || continue
ln -s "$e" "$shim/bin/$(basename "$e")"
done
# The client's bwrap probe (steam-runtime-check-requirements) needs user namespaces, which no Android app has.
rm -f "$shim/bin/steam-runtime-check-requirements"
printf '#!/bin/sh
exit 0
' > "$shim/bin/steam-runtime-check-requirements"
chmod 755 "$shim/bin/steam-runtime-check-requirements"
# Valve's launcher asks a service on the session bus; proot is already the container, so the command runs here.
rm -f "$shim/bin/steam-runtime-launch-client"
cat > "$shim/bin/steam-runtime-launch-client" <<'LAUNCH'
#!/bin/sh
while [ $# -gt 0 ]; do
case $1 in
--) shift; break ;;
--directory=*) cd "${1#--directory=}" || exit 127 ;;
--env=*) export "${1#--env=}" ;;
--unset-env=*) unset "${1#--unset-env=}" ;;
--directory|--env|--unset-env)
[ $# -ge 2 ] || exit 127
case $1 in
--directory) cd "$2" || exit 127 ;;
--env) export "$2" ;;
--unset-env) unset "$2" ;;
esac
shift ;;
esac
shift
done
[ $# -gt 0 ] || exit 0
exec "$@"
LAUNCH
chmod 755 "$shim/bin/steam-runtime-launch-client"
@@ -1113,10 +1113,89 @@ def requested_tool(request, catalog):
def game_requests(directory=None):
value = read_json(state_path("games.json", directory))
if value.get("version") != 1 or not isinstance(value.get("games"), dict):
return {}
return value["games"]
return read_game_requests(directory)[0]
def read_game_requests(directory=None):
try:
with open(state_path("games.json", directory), encoding="utf-8") as f:
text = f.read()
value = json.loads(text)
except (OSError, ValueError):
return {}, None
if not isinstance(value, dict) or value.get("version") != 1 or not isinstance(value.get("games"), dict):
return {}, text
return value["games"], text
def write_game_requests(requests, original, directory=None):
path = state_path("games.json", directory)
try:
with open(path, encoding="utf-8") as f:
if f.read() != original:
return False
except OSError:
if original is not None:
return False
return write_json(path, {"version": 1, "games": requests})
def valid_game_request(app, request):
return (isinstance(app, str) and re.fullmatch(r"[1-9][0-9]*", app) is not None and int(app) <= 0xFFFFFFFF and
(request is None or isinstance(request, dict) and isinstance(request.get("dir"), str) and
request["dir"] != "" and isinstance(request.get("valve"), bool)))
def settle_game_requests(requests, state, current, catalog, missing_is_cleared=False):
recorded = state.get("games_applied")
if isinstance(recorded, dict):
applied = dict(recorded)
else:
applied = dict(requests) if "tools" in state else {}
by_name = {t["name"]: t for t in catalog}
out = dict(requests)
for app, request in requests.items():
if not valid_game_request(app, request) or app not in applied or applied[app] != request:
continue
if request is None:
del out[app]
continue
wanted = requested_tool(request, catalog)
if wanted is None:
continue
if app in current:
picked = current[app]
elif missing_is_cleared:
picked = ""
else:
continue
if picked == wanted:
continue
tool = by_name.get(picked)
if tool and tool["dir"]:
out[app] = {"valve": tool["valve"], "dir": tool["dir"]}
else:
del out[app]
return out, out != requests
def settled_game_requests(state, current, catalog, missing_is_cleared=False, directory=None):
for _ in range(2):
requests, text = read_game_requests(directory)
settled, moved = settle_game_requests(requests, state, current, catalog, missing_is_cleared)
if not moved or write_game_requests(settled, text, directory):
return settled
return None
def applied_game_requests(requests, overrides, state):
recorded = state.get("games_applied")
before = recorded if isinstance(recorded, dict) else {}
if requests is None:
return dict(before)
return {app: request if app in overrides and overrides[app] is not DEFERRED_GAME_TOOL else before[app]
for app, request in requests.items()
if app in overrides and overrides[app] is not DEFERRED_GAME_TOOL or app in before}
def requested_games(requests, catalog, runnable=None):
@@ -1306,7 +1385,8 @@ def register_default(config_path, apps=(), protect=(), default=None, catalog=Non
else:
default = state.get("default") if state.get("default") in names else TOOL
steam_root = os.path.dirname(os.path.dirname(os.path.abspath(config_path)))
overrides = requested_games(game_requests(directory), catalog)
requests = settled_game_requests(state, current, catalog, not steam_running(), directory)
overrides = requested_games(requests or {}, catalog)
managed = state.get("auto", {}).keys() if isinstance(state.get("auto"), dict) else ()
native_choices = state.get("native_choices", ())
native = native_targets(steam_root, set(apps) | set(picks) | set(managed) | set(native_choices))
@@ -1325,6 +1405,7 @@ def register_default(config_path, apps=(), protect=(), default=None, catalog=Non
state["auto"] = {app: tool for app, tool in auto.items() if tool is not NATIVE_CHOICE}
state["native_choices"] = sorted(app for app, tool in auto.items() if tool is NATIVE_CHOICE)
state["picked"] = picked_after(current, changes)
state["games_applied"] = applied_game_requests(requests, overrides, state)
state.pop("native", None)
state["tools"] = catalog
state.setdefault("default", default)