-
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathboosteroid-launcher.sh
More file actions
executable file
·462 lines (421 loc) · 21.5 KB
/
Copy pathboosteroid-launcher.sh
File metadata and controls
executable file
·462 lines (421 loc) · 21.5 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
#!/bin/bash
# Launcher for the Boosteroid Flatpak.
# On first run: downloads Boosteroid from boosteroid.com and adds a Steam shortcut.
# Subsequent runs: launches the cached binary directly.
#
# Author: Schelstraete Bart
# https://github.com/bschelst/boosteroid-steamos
# https://www.schelstraete.org
set -euo pipefail
# Shared with splash screen for live status updates.
# Lifecycle: absent (no Boosteroid) → "step:/warn:" (waiting for old instance)
# → "boosteroid_running" (Boosteroid is active) → absent on exit.
# The next launcher checks this file first before resorting to pgrep.
# Do NOT blindly rm -f here — the file may be a valid running indicator
# from the previous session. Staleness is handled in _wait_for_boosteroid_close.
STATUS_FILE="${XDG_RUNTIME_DIR:-/run/user/$(id -u)}/.boosteroid_splash_status"
# Ignore SIGTERM during startup so Steam session cleanup cannot kill this
# launcher while it is still in the wait-for-previous-instance loop.
# Default SIGTERM handling is restored just before Boosteroid is launched.
trap 'echo "==> Startup: SIGTERM received, continuing"' TERM
# ── Debug log (check ~/logs/boosteroid.log from Desktop Mode after launch) ───
mkdir -p "$HOME/logs"
mkdir -p "$HOME/Videos/BoosteroidClips"
LOG=$HOME/logs/boosteroid.log
> "$LOG"
exec > >(tee -a "$LOG") 2>&1
VERSION=$(cat /app/share/boosteroid/version 2>/dev/null || echo "unknown")
echo "=== Boosteroid $VERSION launch $(date) ==="
echo "DISPLAY=${DISPLAY:-<unset>} WAYLAND_DISPLAY=${WAYLAND_DISPLAY:-<unset>}"
echo "GAMESCOPE_WAYLAND_DISPLAY=${GAMESCOPE_WAYLAND_DISPLAY:-<unset>}"
echo "DBUS_SESSION_BUS_ADDRESS=${DBUS_SESSION_BUS_ADDRESS:-<unset>}"
# ── Splash screen ────────────────────────────────────────────────────────────
# Show a loading splash early so the user sees something immediately.
# Requires a display (X11 or Wayland); silently skipped if neither is available.
# To disable, add --env=NOSPLASH=1 to Steam launch options:
# run --env=NOSPLASH=1 org.schelstraete.boosteroid
SPLASH_PID=""
if [ "${NOSPLASH:-0}" = "1" ]; then
echo "==> Splash screen disabled (NOSPLASH=1)"
elif [ -n "${DISPLAY:-}" ] || [ -n "${WAYLAND_DISPLAY:-}" ]; then
python3 /app/lib/boosteroid/splash.py &
SPLASH_PID=$!
fi
XDG_DATA_HOME="${XDG_DATA_HOME:-${HOME}/.local/share}"
XDG_RUNTIME_DIR="${XDG_RUNTIME_DIR:-/run/user/$(id -u)}"
# Reject injected XDG_RUNTIME_DIR values that could redirect the xdg-open override
# binary to an unexpected location. Only /run/user/* paths are valid Flatpak runtime dirs.
case "${XDG_RUNTIME_DIR}" in
/run/user/*) ;;
*) XDG_RUNTIME_DIR="/run/user/$(id -u)" ;;
esac
INSTALL_DIR="${XDG_DATA_HOME}/boosteroid"
BINARY="${INSTALL_DIR}/opt/BoosteroidGamesS.R.L./bin/Boosteroid"
LIB_DIR="${INSTALL_DIR}/opt/BoosteroidGamesS.R.L./lib"
CACHE_DIR="${XDG_CACHE_HOME:-${HOME}/.cache}/Boosteroid Games S.R.L./Boosteroid"
# ── Neutralise Boosteroid's broken auto-updater ─────────────────────────────
# Boosteroid has a version ping-pong bug: v1.11.15 downloads a flatpak containing
# v1.10.14, and vice versa, looping forever. Each download triggers an exit.
# Fix: replace the download target with a FIFO (named pipe). The binary's
# download thread blocks on open() waiting for a reader that never comes —
# no error dialog, no exit, the app runs normally.
if flatpak-spawn --host flatpak info com.boosteroid.Client > /dev/null 2>&1; then
echo "==> Cleaning up com.boosteroid.Client (Boosteroid auto-updater artifact)..."
flatpak-spawn --host flatpak uninstall --user -y com.boosteroid.Client 2>/dev/null || true
fi
# ── First-run install ────────────────────────────────────────────────────────
if [ ! -f "${BINARY}" ]; then
echo "==> First launch: downloading Boosteroid..."
python3 /app/lib/boosteroid/install_boosteroid.py
fi
# Always ensure the Steam shortcut exists (idempotent — skips if already present).
# Runs on every launch so reinstalling the flatpak re-adds the shortcut if needed.
echo "==> Ensuring Steam shortcut..."
python3 /app/lib/boosteroid/add-to-steam.py \
|| echo "Warning: could not add Steam shortcut (is Steam installed?)"
# ── AMD GPU optimisation ─────────────────────────────────────────────────────
# Detect AMD GPU via PCI vendor ID (0x1002 = AMD/ATI).
# Sets the radeonsi VA-API driver and passes -vaapi to Boosteroid so hardware
# video decode is used for the stream instead of software decode.
DECODE_FLAG=""
if grep -q "0x1002" /sys/class/drm/renderD128/device/vendor 2>/dev/null; then
export LIBVA_DRIVER_NAME="${LIBVA_DRIVER_NAME:-radeonsi}"
DECODE_FLAG="-vaapi"
fi
# ── Codec / HDR / resolution opt-in flags (experimental) ────────────────────
# Boosteroid's hidden CLI flags discovered via `strings` on the binary:
# -h264 force h264 codec
# -h265 force h265 codec (HEVC — Steam Deck VCN3 supports HW decode)
# -4k advertise 4K capability to the server (useful when Gamescope
# composition is set to 1440p/4K on a docked Deck)
# Pass via Steam launch options, e.g.:
# run --env=BOOSTEROID_FORCE_H265=1 --env=BOOSTEROID_FORCE_4K=1 org.schelstraete.boosteroid
# Or persistently:
# flatpak override --user --env=BOOSTEROID_FORCE_H265=1 org.schelstraete.boosteroid
#
# HDR is auto-detected internally (LinuxPlatform::hdrSupported); the binary
# does NOT expose an -hdr flag. BOOSTEROID_TRY_HDR=1 is best-effort: it sets
# upstream Wayland/Vulkan/Proton HDR env vars and forces -h265 (HDR streams
# are HEVC-only). Whether the Boosteroid client actually advertises HDR to
# the server depends on Qt6 RHI capability detection — see ~/logs/boosteroid.log
# for `HDR support: true|false` after launch.
CODEC_FLAG=""
if [ "${BOOSTEROID_FORCE_H265:-0}" = "1" ]; then
CODEC_FLAG="-h265"
echo "==> BOOSTEROID_FORCE_H265=1: forcing HEVC codec"
elif [ "${BOOSTEROID_FORCE_H264:-0}" = "1" ]; then
CODEC_FLAG="-h264"
echo "==> BOOSTEROID_FORCE_H264=1: forcing H.264 codec"
fi
RES_FLAG=""
if [ "${BOOSTEROID_FORCE_4K:-0}" = "1" ]; then
RES_FLAG="-4k"
echo "==> BOOSTEROID_FORCE_4K=1: advertising 4K capability to server"
fi
if [ "${BOOSTEROID_TRY_HDR:-0}" = "1" ]; then
echo "==> BOOSTEROID_TRY_HDR=1: best-effort HDR (no native Boosteroid flag exists)"
export ENABLE_HDR_WSI=1
export DXVK_HDR=1
export PROTON_ENABLE_HDR=1
export QT_RHI_HDR=scrgb
# HDR streams are always HEVC; force -h265 so the client doesn't downshift.
if [ -z "${CODEC_FLAG}" ]; then
CODEC_FLAG="-h265"
echo "==> BOOSTEROID_TRY_HDR=1: forcing -h265 (HDR requires HEVC)"
fi
fi
# ── Google login (xdg-open via host) ────────────────────────────────────────
# In Game Mode (Gamescope) there is no traditional desktop environment, so the
# Flatpak portal and host xdg-open may not work reliably. The most reliable
# approach is to use Steam's built-in browser via the steam://openurl/ protocol.
# Steam is always running in Game Mode and its overlay browser can follow the
# loopback OAuth redirect (http://localhost:PORT/callback) because the Flatpak
# sandbox shares the host network namespace (--share=network).
# Fallback: host xdg-open works in Desktop Mode where a normal browser is running.
_OVERRIDE_BIN="${XDG_RUNTIME_DIR}/boosteroid-bin"
mkdir -p "${_OVERRIDE_BIN}"
# Clean up stale pkexec shim from older versions — /app/bin/pkexec handles this now.
rm -f "${_OVERRIDE_BIN}/pkexec"
cat > "${_OVERRIDE_BIN}/xdg-open" << 'EOF'
#!/bin/bash
URL="$1"
echo "[xdg-open] called with: $URL" >> $HOME/logs/boosteroid.log
# Method 1: Steam overlay browser — works in Game Mode and Desktop Mode on SteamOS.
# Tells the already-running Steam process to open the URL in its built-in browser.
if flatpak-spawn --host steam "steam://openurl/$URL" >> $HOME/logs/boosteroid.log 2>&1; then
echo "[xdg-open] steam://openurl OK" >> $HOME/logs/boosteroid.log
exit 0
fi
echo "[xdg-open] steam://openurl failed, trying host xdg-open" >> $HOME/logs/boosteroid.log
# Method 2: host xdg-open — fallback for Desktop Mode if Steam isn't in PATH.
flatpak-spawn --host xdg-open "$URL" >> $HOME/logs/boosteroid.log 2>&1
echo "[xdg-open] xdg-open exit=$?" >> $HOME/logs/boosteroid.log
EOF
chmod +x "${_OVERRIDE_BIN}/xdg-open"
export PATH="${_OVERRIDE_BIN}:${PATH}"
# ── Wait for any previous Boosteroid instance to exit ────────────────────────
# Detection strategy:
# 1. STATUS_FILE contains the numeric PID written by the previous launcher.
# Check /proc/$pid/comm for "boosteroid" — instant and reliable even if
# the previous launcher was killed before cleanup (SIGKILL).
# 2. Non-PID / absent STATUS_FILE = stale file from old version or crashed
# session. Kill any orphaned pgrep matches immediately and proceed —
# do NOT enter the retry loop. This avoids the warn: state that caused
# the splash to close before Boosteroid launched.
_wait_for_boosteroid_close() {
local _pid="" _should_wait=0
if [ -f "${STATUS_FILE}" ]; then
local _content
_content=$(cat "${STATUS_FILE}" 2>/dev/null || true)
if [[ "${_content}" =~ ^[0-9]+$ ]]; then
_pid="${_content}"
if [ -d "/proc/${_pid}" ] && grep -qi "boosteroid" "/proc/${_pid}/comm" 2>/dev/null; then
echo "==> STATUS_FILE: PID ${_pid} still running (Boosteroid confirmed)"
_should_wait=1
else
echo "==> STATUS_FILE: PID ${_pid} is gone, clearing"
rm -f "${STATUS_FILE}"
fi
else
# Non-PID content = stale file from old version or crashed session.
# Kill any lingering processes and proceed — never retry stale state.
echo "==> STATUS_FILE has stale content (${_content:0:20}...), killing orphaned processes"
rm -f "${STATUS_FILE}"
flatpak-spawn --host pkill -f "BoosteroidGamesS" 2>/dev/null || true
sleep 0.5
fi
else
# No STATUS_FILE. Kill any orphaned processes left by a previous crash.
if flatpak-spawn --host pgrep -f "BoosteroidGamesS" > /dev/null 2>&1; then
echo "==> No STATUS_FILE but orphaned Boosteroid found, killing"
flatpak-spawn --host pkill -f "BoosteroidGamesS" 2>/dev/null || true
sleep 0.5
fi
fi
[ "${_should_wait}" -eq 1 ] || return 0
# Wait for the PID-tracked instance to exit gracefully.
echo "==> Previous Boosteroid (PID ${_pid}) still running, waiting..."
local max_attempts=5 wait_secs=3 i=1
while [ "$i" -le "$max_attempts" ]; do
echo "step:Waiting for previous Boosteroid to close (${i}/${max_attempts})..." \
> "${STATUS_FILE}"
echo "==> Attempt ${i}/${max_attempts}: still running, retrying in ${wait_secs}s..."
sleep "${wait_secs}" || {
echo "==> Wait sleep interrupted — proceeding with launch"
rm -f "${STATUS_FILE}"
return 0
}
if ! { [ -d "/proc/${_pid}" ] && grep -qi "boosteroid" "/proc/${_pid}/comm" 2>/dev/null; }; then
rm -f "${STATUS_FILE}"
echo "==> Previous instance exited OK"
return 0
fi
i=$((i + 1))
done
# Still running after waiting — force-kill and proceed.
echo "==> Force-killing previous Boosteroid (PID ${_pid}) after ${max_attempts} attempts"
flatpak-spawn --host kill -9 "${_pid}" 2>/dev/null || true
sleep 0.5
rm -f "${STATUS_FILE}"
}
_wait_for_boosteroid_close
# ── Portal intercept for Google login ───────────────────────────────────────
# Qt5 calls org.freedesktop.portal.Desktop.OpenURI via D-Bus instead of
# xdg-open, bypassing our PATH wrapper. We claim that portal name on the
# sandbox proxy bus and redirect all OpenURI calls to steam://openurl/ so
# the Steam overlay browser handles Google OAuth in both Game Mode and Desktop.
python3 /app/lib/boosteroid/portal_openuri.py &
sleep 0.3 # let the service register before Boosteroid starts
# ── Force fullscreen ─────────────────────────────────────────────────────────
# Runs in the background: polls for the Boosteroid X11 window and sends it a
# _NET_WM_STATE_FULLSCREEN ClientMessage so it fills the Gamescope display
# without any user interaction.
/app/bin/boosteroid-fullscreen >> "$LOG" 2>&1 &
# ── Launch ───────────────────────────────────────────────────────────────────
# Add Boosteroid's bundled libraries to the search path.
export LD_LIBRARY_PATH="${LIB_DIR}${LD_LIBRARY_PATH:+:${LD_LIBRARY_PATH}}"
# Wait for the splash to finish before starting Boosteroid.
# Boosteroid immediately maps a fullscreen window and Gamescope switches
# focus to it, hiding the splash — so we must launch only after splash exits.
if [ -n "${SPLASH_PID}" ]; then
wait "${SPLASH_PID}" 2>/dev/null || true
fi
# ── Session stats ────────────────────────────────────────────────────────────
# Steam kills games with SIGKILL in Game Mode, so exit handlers never run.
# Strategy: write start timestamp, then on NEXT launch close any unclosed session
# by calculating duration from the start timestamp.
STATS_FILE="$HOME/logs/boosteroid-stats.csv"
if [ ! -f "$STATS_FILE" ]; then
echo "timestamp,event,version,duration_s,decoder" > "$STATS_FILE"
fi
# Close any previous unclosed session (last line is a "start" with no matching "end").
_close_previous_session() {
local last_line last_event start_ts start_epoch end_epoch dur
last_line=$(tail -1 "$STATS_FILE")
last_event=$(echo "$last_line" | cut -d',' -f2)
if [ "$last_event" = "start" ]; then
start_ts=$(echo "$last_line" | cut -d',' -f1)
start_epoch=$(date -d "$start_ts" +%s 2>/dev/null) || return
# Use boosteroid.log mtime as the best estimate of when the session ended.
if [ -f "$LOG" ]; then
end_epoch=$(stat -c %Y "$LOG" 2>/dev/null) || end_epoch=$(date +%s)
else
end_epoch=$(date +%s)
fi
dur=$((end_epoch - start_epoch))
if [ "$dur" -lt 0 ] || [ "$dur" -gt 86400 ]; then
dur=0
fi
echo "$(date -d "@${end_epoch}" -Iseconds 2>/dev/null || date -Iseconds),end,${VERSION},${dur},$(echo "$last_line" | cut -d',' -f5)" >> "$STATS_FILE"
echo "==> Closed previous session (${dur}s, from log mtime)"
fi
}
_close_previous_session
# ── Session keepalive window ─────────────────────────────────────────────────
# A minimal dark window that sits BEHIND Boosteroid. Keeps the Gamescope
# session alive when Boosteroid exits for an auto-update. Invisible during
# normal gameplay (Boosteroid is fullscreen on top). Killed immediately on
# normal exit so the user never sees it.
_KEEPALIVE_PID=""
if [ -n "${DISPLAY:-}" ] || [ -n "${WAYLAND_DISPLAY:-}" ]; then
python3 -c "
import gi
gi.require_version('Gtk', '3.0')
from gi.repository import Gtk, Gdk
css = Gtk.CssProvider()
css.load_from_data(b'window { background: #1a1a2e; }')
Gtk.StyleContext.add_provider_for_screen(
Gdk.Screen.get_default(), css, Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION)
w = Gtk.Window()
w.set_decorated(False)
w.fullscreen()
w.show_all()
Gtk.main()
" &
_KEEPALIVE_PID=$!
sleep 0.3
fi
# ── Filter debug output unless DEBUG=1 ──────────────────────────────────────
# By default [debug] lines from Boosteroid are stripped from the log.
# To keep them, add --env=DEBUG=1 to Steam launch options:
# run --env=DEBUG=1 org.schelstraete.boosteroid
#
# Run Boosteroid in the background so we can capture its PID and write it to
# STATUS_FILE. The next launcher reads that PID and checks /proc/$pid/comm —
# no age heuristic, works correctly even if this launcher is SIGKILL'd.
# shellcheck disable=SC2086
if [ "${DEBUG:-0}" = "1" ]; then
echo "==> Debug mode ON: [debug] lines will appear in log"
"${BINARY}" ${DECODE_FLAG} ${CODEC_FLAG} ${RES_FLAG} "$@" &
else
# Process substitution keeps $! as Boosteroid's PID (not grep's).
"${BINARY}" ${DECODE_FLAG} ${CODEC_FLAG} ${RES_FLAG} "$@" > >(grep --line-buffered -v '\[debug\]') 2>&1 &
fi
BOOSTEROID_PID=$!
echo "${BOOSTEROID_PID}" > "${STATUS_FILE}"
echo "==> Boosteroid started (PID ${BOOSTEROID_PID}) flags: ${DECODE_FLAG} ${CODEC_FLAG} ${RES_FLAG}"
echo "$(date -Iseconds),start,${VERSION},0,${DECODE_FLAG:--none-}${CODEC_FLAG:+ ${CODEC_FLAG}}${RES_FLAG:+ ${RES_FLAG}}" >> "$STATS_FILE"
wait "${BOOSTEROID_PID}"
EXIT_CODE=$?
# Boosteroid's built-in updater replaces the binary on disk while the old process
# is still alive, causing a segfault (signal 139). The update succeeded — the
# user just needs to relaunch.
if [ "$EXIT_CODE" -eq 139 ] && [ -f /tmp/BoosteroidUpdater ]; then
echo "==> Boosteroid updated itself. Please relaunch to use the new version."
fi
# Calculate session duration now — needed by the update block below.
SESSION_END=$(date +%s)
SESSION_START_TS=$(tail -1 "$STATS_FILE" | cut -d',' -f1)
SESSION_START_EPOCH=$(date -d "$SESSION_START_TS" +%s 2>/dev/null || echo "$SESSION_END")
SESSION_DUR=$((SESSION_END - SESSION_START_EPOCH))
echo "==> Session duration: ${SESSION_DUR}s"
# ── Post-exit: wait for auto-updater, then clean up ─────────────────────────
# The background overlay is already visible (Boosteroid's window is gone).
# If the updater is installing com.boosteroid.Client, wait for it, clean up,
# then exit — the user will see the overlay while waiting.
if flatpak-spawn --host flatpak info com.boosteroid.Client > /dev/null 2>&1 \
|| [ -f "${CACHE_DIR}/Boosteroid.flatpak" ]; then
echo "==> Boosteroid auto-updater active — showing update overlay..."
# Replace the blank keepalive with the text overlay
[ -n "${_KEEPALIVE_PID}" ] && kill "${_KEEPALIVE_PID}" 2>/dev/null
_KEEPALIVE_PID=""
if [ -n "${DISPLAY:-}" ] || [ -n "${WAYLAND_DISPLAY:-}" ]; then
python3 -c "
import gi
gi.require_version('Gtk', '3.0')
from gi.repository import Gtk, Gdk, GLib
css = Gtk.CssProvider()
css.load_from_data(b'''
window { background: #1a1a2e; }
label { color: rgba(255,255,255,0.85); }
.title { font-size: 28px; font-weight: 300; }
.sub { font-size: 16px; color: rgba(255,255,255,0.45); }
.dots { font-size: 20px; color: rgba(79,195,247,0.7); }
''')
Gtk.StyleContext.add_provider_for_screen(
Gdk.Screen.get_default(), css, Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION)
w = Gtk.Window()
w.set_decorated(False)
w.fullscreen()
b = Gtk.Box(orientation=Gtk.Orientation.VERTICAL, spacing=12)
b.set_valign(Gtk.Align.CENTER)
b.set_halign(Gtk.Align.CENTER)
t = Gtk.Label(label='Updating Boosteroid')
t.get_style_context().add_class('title')
d = Gtk.Label(label='.')
d.get_style_context().add_class('dots')
s = Gtk.Label(label='This may take a moment')
s.get_style_context().add_class('sub')
r = Gtk.Label(label='Please restart the application after this screen closes')
r.get_style_context().add_class('sub')
r.set_margin_top(24)
b.add(t)
b.add(d)
b.add(s)
b.add(r)
w.add(b)
_n = [0]
def _tick():
_n[0] = (_n[0] % 3) + 1
d.set_text('.' * _n[0])
return True
GLib.timeout_add(600, _tick)
w.show_all()
Gtk.main()
" &
_KEEPALIVE_PID=$!
fi
# Wait for install to complete
for _i in $(seq 1 20); do
if flatpak-spawn --host flatpak info com.boosteroid.Client > /dev/null 2>&1; then
echo "==> com.boosteroid.Client installed"
break
fi
sleep 2
done
# Wait for the post-install launch attempt to crash
echo "==> Waiting for updater to settle..."
sleep 8
# Always copy from com.boosteroid.Client — respects user-initiated
# upgrades AND downgrades (stable/unstable channel switches).
_client_base="${HOME}/.local/share/flatpak/app/com.boosteroid.Client/x86_64/master/active/files"
_client_bin="${_client_base}/bin/Boosteroid"
if flatpak-spawn --host test -f "${_client_bin}" 2>/dev/null; then
echo "==> Copying binary from com.boosteroid.Client"
flatpak-spawn --host cp "${_client_bin}" "${BINARY}" 2>&1 || true
fi
# Clean up
flatpak-spawn --host flatpak uninstall --user -y com.boosteroid.Client 2>/dev/null || true
rm -f "${CACHE_DIR}/Boosteroid.flatpak" 2>/dev/null || true
echo "==> Cleanup complete"
fi
# Kill the keepalive/overlay window
[ -n "${_KEEPALIVE_PID}" ] && kill "${_KEEPALIVE_PID}" 2>/dev/null
# Write session end
echo "$(date -Iseconds),end,${VERSION},${SESSION_DUR},${DECODE_FLAG:--none-}" >> "$STATS_FILE"
# Remove the running indicator now that Boosteroid has exited.
rm -f "${STATUS_FILE}"
echo "==> Boosteroid exited"
# Kill background helpers (portal_openuri.py, boosteroid-fullscreen) so the
# sandbox can exit cleanly — they hold the tee pipe open, blocking bwrap.
kill $(jobs -p) 2>/dev/null || true