End Steam shortcuts when the Android app closes

This commit is contained in:
Kurt Himebauch committed 2026-12-06 07:34:44 -05:00
1 parent fb2a1445b1
commit 66c74fdac2
4 files changed
+108 -5

No files matched your search

@@ -1,5 +1,5 @@
#!/bin/sh
set -eu
#!/bin/bash
set -euo pipefail
fail() {
printf 'droiddeck-android-app: %s\n' "$1" >&2
@@ -32,7 +32,12 @@ exec 9>"${XDG_RUNTIME_DIR:-/tmp}/droiddeck-android-app.lock"
flock -n 9 || fail "Close the running Android app shortcut first."
# The ADB server must not inherit the lock.
adb start-server 9>&- || fail "Could not start the Android connection."
trap 'adb kill-server 9>&- >/dev/null 2>&1 || true' EXIT
output=
cleanup() {
adb kill-server 9>&- >/dev/null 2>&1 || true
[ -z "$output" ] || rm -f "$output"
}
trap cleanup EXIT
trap 'exit 0' INT TERM HUP
connected() {
timeout 8 adb connect "$serial" 9>&- >/dev/null 2>&1 || true
@@ -41,9 +46,11 @@ connected() {
connected || connected ||
fail "Android is disconnected. Turn on Wireless debugging, then restart Steam."
output=$(mktemp)
export SDL_VIDEODRIVER=x11
# Android plays audio on the handheld. Capturing it here would feed it back into Android again.
scrcpy --serial "$serial" --new-display=1280x720/240 --start-app="$package" \
--window-title="Android app" --no-vd-system-decorations --no-clipboard-autosync --no-mouse-hover \
--mouse-bind=----:---- --gamepad=uhid --no-audio --max-fps=60 9>&- ||
--mouse-bind=----:---- --gamepad=uhid --no-audio --max-fps=60 9>&- 2>&1 | tee "$output" ||
grep -Fq '[server] INFO: DroidDeck Android shortcut ended' "$output" ||
fail "The Android app window closed unexpectedly. Try launching it again."