#!/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 ] && [ "${DD_DESKTOP:-}" = 1 ]; then case ",${MESA_VK_WSI_DEBUG:-}," in *,sw,*) ;; *) export MESA_VK_WSI_DEBUG=${MESA_VK_WSI_DEBUG:+$MESA_VK_WSI_DEBUG,}sw ;; esac if [ "${DD_STEAM_CLIENT_ARCH:-}" = x86_64 ]; then client_home=${DD_X64_HOME:-${HOME:-/root}/.droiddeck-x64} client=(/usr/local/bin/droiddeck-steam-x64 --exec) else 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} client_home=$HOME client=("$steam_root/steamrtarm64/steam") fi if [ "${DD_BOTTOM_DESKTOP:-}" = 1 ]; then pid=$(cat "$client_home/.steam/steam.pid" 2>/dev/null || true) if [ -p "$client_home/.steam/steam.pipe" ] && [[ "$pid" =~ ^[0-9]+$ ]] && kill -0 "$pid" 2>/dev/null; then # The top screen's client takes the request, so games open there. exec "${client[@]}" -nobigpicture -no-cef-sandbox \ -cef-ozone-platform=x11 -cef-disable-gpu "${url:-steam://open/library}" fi fi 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 "$client_home/.steam/steam.pid" 2>/dev/null || true) if [ -p "$client_home/.steam/steam.pipe" ] && [[ "$pid" =~ ^[0-9]+$ ]] && kill -0 "$pid" 2>/dev/null; then exec "${client[@]}" -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 [ "$url" = steam://exit ] && exit 0 export DD_INSIDE=1 DD_STEAM_UI=desktop exec /usr/local/bin/droiddeck-session steam "${url:-steam://open/library}" fi dir=${DD_LAUNCH_DIR:-} if [ -z "$dir" ] || [ ! -d "$dir" ]; then echo "droiddeck-steam-launch: not inside a DroidDeck session (DD_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})"