Fix runtime removal and first-run Steam setup (#185)

* Fix runtime removal races and show removal progress

* Bootstrap Steam from the selected client channel

* Show runtime progress below its Setup row

* Always stage current session helpers and verify APK assets

* Initialize Steam UI scale once using the handheld default
This commit is contained in:
Kurt Himebauch authored and GitHub committed 2026-10-03 22:03:26 -04:00
1 parent f5e204eb1d
commit db2e1d7da2
27 files changed
+978 -90

No files matched your search

@@ -323,6 +323,9 @@ case $mode in
bannerlator-steam-library "$steam_root" || true
step "setting up the ARM64 Proton compatibility tool"
bannerlator-steam-compat "$steam_root" || true
if [ -z "${BL_DESKTOP:-}" ] && [ "${BL_STEAM_UI:-}" != desktop ]; then
bannerlator-steam-ui-scale "$steam_root" "${BL_WIDTH:-1280}" "${BL_HEIGHT:-720}" || true
fi
# The user's own games, as non-Steam shortcuts under that tool; the list is written by the app
# each session (empty = the app's earlier entries are removed, the client's own are kept).
if [ -n "${BL_ADDED_GAMES:-}" ]; then
@@ -667,14 +670,13 @@ BUSCONF
[ -n "$_stale" ] && echo "== steam: cleared what an earlier session left:$_stale"
unset _stale _f
fi
# The client branch. publicbeta is what every session has run on; steamdeck_publicbeta is the
# channel Armada bootstraps its ARM64 client from. Whatever wrote package/beta, the branch on
# Use the same configured branch as the first-run download. Whatever wrote package/beta, the branch on
# disk has to agree with the one forced here - a disagreement is the restart loop above, and
# it is silent apart from rc=42 in this log.
# Checked before every start, not once: the client rewrites package/beta during its own run,
# and a restart below (rc=42, or the one after the ARM64 Proton lands) would otherwise start it
# again on the branch it just wrote.
steam_channel=${BL_STEAM_CHANNEL:-publicbeta}
steam_channel=${BL_STEAM_CHANNEL:-steamdeck_publicbeta}
steam_beta=$steam_root/package/beta
if [ -n "${BL_ADDED_GAMES:-}" ] && [ -f "$BL_ADDED_GAMES" ]; then
bannerlator-steam-games watch "$steam_root" "$BL_ADDED_GAMES" &
@@ -3,7 +3,12 @@
# The client is not redistributable, so the runtime ships this script instead of the client.
set -eu
cdn=https://client-update.fastly.steamstatic.com
manifest=steam_client_publicbeta_linuxarm64
steam_channel=${BL_STEAM_CHANNEL:-steamdeck_publicbeta}
case "$steam_channel" in
publicbeta|steamdeck_publicbeta) ;;
*) echo "bannerlator-steam-install: unsupported Steam channel: $steam_channel" >&2; exit 1 ;;
esac
manifest=steam_client_${steam_channel}_linuxarm64
steam_root=${XDG_DATA_HOME:-$HOME/.local/share}/Steam
stamp=$steam_root/package/bannerlator-installed
[ -x "$steam_root/steamrtarm64/steam" ] && [ -f "$stamp" ] && exit 0
@@ -41,8 +46,7 @@ find "$steam_root" -depth -name '*\\*' | while read -r odd; do
mv -f "$odd" "$fixed"
fi
done
echo publicbeta > "$steam_root/package/beta"
echo "$version" > "$stamp"
echo "$steam_channel" > "$steam_root/package/beta"
ln -sfn "$steam_root/steamrtarm64" "$steam_root/steamrtarm32"
chmod +x "$steam_root/steamrtarm64/steam" 2>/dev/null || true
# What Valve's steam.sh sets up before it runs the client (it has no arm64 branch itself).
@@ -59,3 +63,4 @@ ln -sfn "$steam_root/linuxarm64" "$HOME/.steam/sdk64"
ln -sfn "$steam_root/linuxarm64" "$HOME/.steam/sdkarm64"
ln -sfn "$steam_root/steamrtarm64" "$HOME/.steam/binarm64"
ln -sfn "$steam_root/linux32" "$HOME/.steam/sdk32"
echo "$version" > "$stamp"
@@ -0,0 +1,136 @@
#!/usr/bin/python3
"""Initialize Steam's own Gamescope UI scale once; subsequent choices belong to Steam."""
import math
import os
from pathlib import Path
import re
import sys
import tempfile
DISPLAY = "External: gamescope|||Windowed"
TOKEN = re.compile(r'\s+|//[^\n]*|"(?:\\.|[^"\\])*"|[{}]')
class Block:
def __init__(self, pairs, end):
self.pairs = pairs
self.end = end
def get(self, name):
matches = [value for key, value in self.pairs if key.lower() == name.lower()]
if len(matches) > 1:
raise ValueError("duplicate UI setting")
return matches[0] if matches else None
def parse(text):
tokens = []
position = 0
for match in TOKEN.finditer(text):
if match.start() != position:
raise ValueError("invalid config.vdf")
position = match.end()
token = match.group()
if not token.isspace() and not token.startswith('//'):
tokens.append((token, match.start()))
if position != len(text):
raise ValueError("invalid config.vdf")
def block(index, nested=False):
pairs = []
while index < len(tokens):
token, offset = tokens[index]
if token == '}':
if not nested:
raise ValueError("unexpected closing brace")
return Block(pairs, offset), 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]
index += 2
if value == '{':
value, index = block(index, True)
elif value.startswith('"'):
value = value[1:-1]
else:
raise ValueError("invalid config value")
pairs.append((key, value))
if nested:
raise ValueError("unclosed config block")
return Block(pairs, len(text)), index
return block(0)[0]
def initial_scale(width, height):
# The Thor setting chosen on device at 1280x720 was 140% of its automatic scale.
# Adjust with canvas area so choosing a different session resolution keeps the UI usable.
if not 320 <= width <= 16384 or not 320 <= height <= 16384:
raise ValueError("invalid session size")
return 1.3281567096710205 * math.sqrt(width * height / (1280 * 720))
def seed_text(text, scale):
root = parse(text).get('InstallConfigStore')
if not isinstance(root, Block):
raise ValueError("missing InstallConfigStore")
ui = root.get('UI')
display = ui.get('display') if isinstance(ui, Block) else None
if ui is not None and not isinstance(ui, Block):
raise ValueError("invalid UI settings")
if display is not None and not isinstance(display, Block):
raise ValueError("invalid display settings")
if display is not None:
# Current describes the active display and is written even with automatic scaling.
# Named display entries are the user's saved choices, including a return to Auto.
if any(name.lower() != 'current' and isinstance(value, Block)
and value.get('ScaleFactor') is not None for name, value in display.pairs):
return text, False
entry = f'"{DISPLAY}"\n{{\n"ScaleFactor" "{scale:.9f}"\n}}\n'
if display is not None:
at, indent = display.end, 3
elif ui is not None:
entry = '"display"\n{\n' + entry + '}\n'
at, indent = ui.end, 2
else:
entry = '"UI"\n{\n"display"\n{\n' + entry + '}\n}\n'
at, indent = root.end, 1
# Insert only the new block; leave every existing byte, comment and credential untouched.
insertion = '\n' + '\n'.join('\t' * indent + line for line in entry.splitlines()) + '\n'
return text[:at] + insertion + text[at:], True
def atomic_write(path, text):
path.parent.mkdir(parents=True, exist_ok=True)
fd, temporary = tempfile.mkstemp(prefix='.' + path.name, dir=path.parent)
try:
with os.fdopen(fd, 'w') as output:
output.write(text)
os.replace(temporary, path)
finally:
if os.path.exists(temporary):
os.unlink(temporary)
def initialize(steam_root, width, height):
config = Path(steam_root) / 'config/config.vdf'
marker = config.with_name('droiddeck-ui-scale-initialized')
if marker.exists():
return False
text = config.read_text() if config.exists() else '"InstallConfigStore"\n{\n}\n'
updated, changed = seed_text(text, initial_scale(width, height))
if changed:
atomic_write(config, updated)
print(f'== steam: initial handheld UI scale {initial_scale(width, height):.3f}')
atomic_write(marker, '1\n')
return changed
if __name__ == '__main__':
try:
initialize(sys.argv[1], int(sys.argv[2]), int(sys.argv[3]))
except (OSError, ValueError, RecursionError) as error:
print('== steam: left UI scale unchanged: ' + str(error), file=sys.stderr)
sys.exit(1)