mirror of
https://github.com/Droid-Deck/DroidDeck.git
synced 2026-11-19 04:46:08 +00:00
42 lines
1.7 KiB
Bash
Executable File
42 lines
1.7 KiB
Bash
Executable File
#!/bin/bash
|
|
set -u
|
|
ui=${1:-desktop}
|
|
target=${2:-}
|
|
case $ui in desktop|bigpicture) ;; *) echo "usage: $0 desktop|bigpicture [appid|steam://url]" >&2; exit 64 ;; esac
|
|
url=
|
|
case $target in
|
|
"") ;;
|
|
steam://*) url=$target ;;
|
|
*[!0-9]*) echo "not an app id or steam:// URL: $target" >&2; exit 64 ;;
|
|
*) url=steam://rungameid/$target ;;
|
|
esac
|
|
|
|
if [ "$ui" = desktop ] && [ "${BL_DESKTOP:-}" = 1 ]; then
|
|
steam_root=${XDG_DATA_HOME:-${HOME:-/root}/.local/share}/Steam
|
|
export LD_LIBRARY_PATH=$steam_root/steamrtarm64:$steam_root/steamrtarm64/panorama${LD_LIBRARY_PATH:+:$LD_LIBRARY_PATH}
|
|
mkdir -p "${XDG_CACHE_HOME:-$HOME/.cache}/droiddeck"
|
|
exec 9>"${XDG_CACHE_HOME:-$HOME/.cache}/droiddeck/steam-desktop.lock"
|
|
if ! flock -n 9; then
|
|
for ((attempt = 0; attempt < 180; attempt++)); do
|
|
pid=$(cat "$HOME/.steam/steam.pid" 2>/dev/null || true)
|
|
if [ -p "$HOME/.steam/steam.pipe" ] && [[ "$pid" =~ ^[0-9]+$ ]] && kill -0 "$pid" 2>/dev/null; then
|
|
exec "$steam_root/steamrtarm64/steam" -nobigpicture -no-cef-sandbox \
|
|
-cef-ozone-platform=x11 -cef-disable-gpu "${url:-steam://open/library}"
|
|
fi
|
|
sleep 0.5
|
|
done
|
|
echo "droiddeck-steam-launch: the desktop client did not become ready" >&2
|
|
exit 69
|
|
fi
|
|
export BL_INSIDE=1 BL_STEAM_UI=desktop
|
|
exec /usr/local/bin/droiddeck-session steam "${url:-steam://open/library}"
|
|
fi
|
|
|
|
dir=${BL_LAUNCH_DIR:-}
|
|
if [ -z "$dir" ] || [ ! -d "$dir" ]; then
|
|
echo "droiddeck-steam-launch: not inside a DroidDeck session (BL_LAUNCH_DIR unset)" >&2
|
|
exit 69
|
|
fi
|
|
printf 'ui=%s\nurl=%s\n' "$ui" "$url" > "$dir/steam-launch.tmp" && mv -f "$dir/steam-launch.tmp" "$dir/steam-launch"
|
|
echo "droiddeck-steam-launch: asked the app for Steam ($ui${url:+, $url})"
|