From 6e69f252f63d48319eb4f37c05a090101f1ebef8 Mon Sep 17 00:00:00 2001 From: The412Banner Date: Thu, 24 Sep 2026 18:56:24 -0400 Subject: [PATCH] Desktop: the Steam and Big Picture launchers run the client on the desktop itself --- .../launcher/session/SessionService.kt | 16 ++++--- .../overlay/usr/local/bin/bannerlator-session | 15 ++++++- .../usr/local/bin/bannerlator-steam-launch | 42 ++++++++++++++++--- .../usr/local/bin/bannerlator-steam-shim | 17 +++++--- 4 files changed, 71 insertions(+), 19 deletions(-) diff --git a/app/src/main/java/com/droiddeck/launcher/session/SessionService.kt b/app/src/main/java/com/droiddeck/launcher/session/SessionService.kt index ec15c5c2c6..7515762d7e 100644 --- a/app/src/main/java/com/droiddeck/launcher/session/SessionService.kt +++ b/app/src/main/java/com/droiddeck/launcher/session/SessionService.kt @@ -170,7 +170,8 @@ class SessionService : Service() { SessionState.steamUrl = intent?.getStringExtra(EXTRA_STEAM_URL) // Another Steam client on the device signs ours out seconds after every login; the one that // does it here runs from boot without being opened. Only the Steam session signs in. - if (SessionState.mode == MODE_STEAM) RivalClients.stopBeforeSession(this) + // The desktop too: its Steam launchers run the client right there (bannerlator-steam-launch). + if (SessionState.mode == MODE_STEAM || SessionState.mode == MODE_DESKTOP) RivalClients.stopBeforeSession(this) SessionState.running = true SessionState.firstFrameSeen = false // This session's number, claimed here and not when its process starts: the session it @@ -303,7 +304,10 @@ class SessionService : Service() { if (SessionPrefs.glThread(this)) guest.add("mesa_glthread=true") if (SessionPrefs.noGlError(this)) guest.add("MESA_NO_ERROR=1") if (SessionState.mode == MODE_STEAM) guest.add("BL_STEAMDECK=" + (if (SessionPrefs.steamDeckMode(this)) "1" else "0")) - if (SessionState.mode == MODE_STEAM) guest.add("BL_STEAM_CHANNEL=" + SessionPrefs.steamChannel(this)) + // The desktop's Steam launchers start the client there (bannerlator-steam-launch), through the + // same set-up as a Steam session: it gets what the client and its games are started with. + val steamHere = SessionState.mode == MODE_STEAM || SessionState.mode == MODE_DESKTOP + if (steamHere) guest.add("BL_STEAM_CHANNEL=" + SessionPrefs.steamChannel(this)) if (SessionState.mode == MODE_STEAM) { guest.add("BL_GAMESCOPE_FORCE_FULLSCREEN=" + (if (SessionPrefs.forceFullscreen(this)) "1" else "0")) SessionPrefs.writeForceFullscreenFlag(this) @@ -315,7 +319,7 @@ class SessionService : Service() { // The FEXCore preset for the x86 games the client launches: its FEX_* variables go in // here, before the script, so every game process inherits them from the client. The // default preset sets nothing, which is what every session ran on before. - if (SessionState.mode == MODE_STEAM) { + if (steamHere) { val preset = SessionPrefs.fexPreset(this) val vars = com.droiddeck.launcher.core.FexPreset.env(preset) vars.forEach { guest.add(it) } @@ -330,7 +334,7 @@ class SessionService : Service() { // on, even naming every core: it exists to undo the pin Steam applies to its own interface // renderer, and the scheduler's default is exactly what that pin takes away. A game's is // sent only when it is a real restriction - a game has no pin of its own to undo. - if (SessionState.mode == MODE_STEAM && SessionPrefs.clientCpusOverride(this)) { + if (steamHere && SessionPrefs.clientCpusOverride(this)) { guest.add("BL_CLIENT_CPUS=" + CpuCores.listOrAll(SessionPrefs.clientCpus(this))) } // The game cores also pin the desktop and a program from the rail; without a choice the @@ -432,7 +436,7 @@ class SessionService : Service() { } // The user's own games, for the runtime's shortcuts writer to put in the client's library // before the client starts (see frontend/AddedGames and bannerlator-steam-shortcuts). - if (SessionState.mode == MODE_STEAM) { + if (steamHere) { val added = com.droiddeck.launcher.frontend.AddedGames.scan(this) val listing = com.droiddeck.launcher.frontend.AddedGames.writeListing(this, added) guest.add("BL_ADDED_GAMES=" + listing.path) @@ -567,7 +571,7 @@ class SessionService : Service() { // Whether the client signs in to Valve or starts offline: read once, while it starts, and // rewritten by the client when it exits, so it is set again here at every session start. - if (SessionState.mode == MODE_STEAM) OfflineMode.apply(this, root) + if (SessionState.mode == MODE_STEAM || SessionState.mode == MODE_DESKTOP) OfflineMode.apply(this, root) val networkLink = LinuxNetworkLinkComponent(this, root) networkLink.attach(this) diff --git a/tools/linuxfs/overlay/usr/local/bin/bannerlator-session b/tools/linuxfs/overlay/usr/local/bin/bannerlator-session index bdcc653c9e..c54bcecd3e 100755 --- a/tools/linuxfs/overlay/usr/local/bin/bannerlator-session +++ b/tools/linuxfs/overlay/usr/local/bin/bannerlator-session @@ -350,7 +350,8 @@ case $mode in # The drawer's "Stretch games to fill the screen" works live: the app writes its choice to # ~/.droiddeck-fill, and each change goes to gamescope as GAMESCOPE_FORCE_WINDOWS_FULLSCREEN on # the root window, which it watches. What gamescope was started with is where this begins. - ( + # Not on the desktop (BL_DESKTOP): no gamescope there, and the loop would outlive the client. + [ -z "${BL_DESKTOP:-}" ] && ( last=${BL_GAMESCOPE_FORCE_FULLSCREEN:-1} while :; do sleep 1 @@ -515,7 +516,17 @@ BUSCONF # The URL arguments were acted on the first time; a restart must not repeat them. set -- done - reap_orphans + if [ -n "${BL_DESKTOP:-}" ]; then + # Started from the desktop (bannerlator-steam-launch): the desktop's own programs share this + # script's parent, so reap_orphans - right under gamescope, where everything is the client's - + # is not for here. The helpers this run started (the cores and redistributables beats, the + # system bus and the NetworkManager stand-in) go with the client instead. + _bl_jobs=$(jobs -p) + [ -n "$_bl_jobs" ] && kill $_bl_jobs 2>/dev/null + echo "== steam: the client on the desktop has exited" + else + reap_orphans + fi exit "$rc" ;; *) diff --git a/tools/linuxfs/overlay/usr/local/bin/bannerlator-steam-launch b/tools/linuxfs/overlay/usr/local/bin/bannerlator-steam-launch index 1b2afba0a8..92d1c9d22d 100755 --- a/tools/linuxfs/overlay/usr/local/bin/bannerlator-steam-launch +++ b/tools/linuxfs/overlay/usr/local/bin/bannerlator-steam-launch @@ -1,12 +1,18 @@ #!/bin/bash -# Asks the app to start the Steam client, from inside a session (the desktop's menu entries and -# the per-game launchers bannerlator-desktop-games writes): +# Starts the Steam client from inside a session (the desktop's menu entries and the per-game +# launchers bannerlator-desktop-games writes): # bannerlator-steam-launch desktop [appid|steam-url] Steam's desktop UI, optionally a game # bannerlator-steam-launch bigpicture [appid|steam-url] Big Picture -# The client cannot run on the desktop: labwc composites in software and offers no dma-buf, so a -# game (or the client's own Vulkan window) would die at its first frame. It runs under gamescope, -# which is a session of its own - so this writes a request into the directory the app watches, -# and the app ends the desktop session and starts a Steam session in its place. +# +# On a desktop that draws with the GPU (labwc on vulkan or gles2 - the default since the GPU +# desktop) the client runs right there: a window on the desktop, through the desktop's Xwayland, +# with the same set-up a Steam session gives it (bannerlator-session steam, minus gamescope), and +# its games open in windows of their own. A client already running there gets the request instead +# of a second one being started. +# +# On a software desktop (pixman: the GPU renderers failed on this device) there is no dma-buf, so a +# game - or the client's own Vulkan window - would die at its first frame. There the request goes +# to the app, which ends the desktop and starts a Steam session under gamescope in its place. set -u ui=${1:-desktop} target=${2:-} @@ -18,6 +24,30 @@ case $target in *[!0-9]*) echo "not an app id or steam:// URL: $target" >&2; exit 64 ;; *) url=steam://rungameid/$target ;; esac + +steam_root=${XDG_DATA_HOME:-${HOME:-/root}/.local/share}/Steam +client=$steam_root/steamrtarm64/steam + +if [ "${BL_DESKTOP:-}" = 1 ] && [ -n "${WLR_RENDERER:-}" ] && [ "$WLR_RENDERER" != pixman ]; then + log=${BL_DEBUG_DIR:-$HOME/.cache/droiddeck}/steam-desktop.log + mkdir -p "$(dirname "$log")" 2>/dev/null + if pgrep -f 'steamrtarm64/steam( |$)' >/dev/null 2>&1 && [ -x "$client" ]; then + # One client at a time: the running one takes the request (a second start hands its command + # line over and exits). No game asked for = switch it to the UI that was clicked. + [ -n "$url" ] || { [ "$ui" = bigpicture ] && url=steam://open/bigpicture || url=steam://open/main; } + echo "bannerlator-steam-launch: the client is running on the desktop; handing it $url" | tee -a "$log" + exec "$client" "$url" + fi + echo "bannerlator-steam-launch: starting the Steam client on the desktop ($ui${url:+, $url}); log: $log" + # BL_INSIDE: the session script's Steam start-up without gamescope in front of it. The desktop UI + # unless Big Picture was asked for; never Deck mode (its Quick Access Menu needs gamescope). + export BL_INSIDE=1 BL_STEAMDECK=0 + if [ "$ui" = desktop ]; then export BL_STEAM_UI=desktop; else unset BL_STEAM_UI; fi + setsid /usr/local/bin/bannerlator-session steam ${url:+"$url"} >>"$log" 2>&1 < /dev/null & + exit 0 +fi + +# The software desktop, or outside the desktop: ask the app for a Steam session. dir=${BL_LAUNCH_DIR:-} if [ -z "$dir" ] || [ ! -d "$dir" ]; then echo "bannerlator-steam-launch: not inside a DroidDeck session (BL_LAUNCH_DIR unset)" >&2 diff --git a/tools/linuxfs/overlay/usr/local/bin/bannerlator-steam-shim b/tools/linuxfs/overlay/usr/local/bin/bannerlator-steam-shim index 66d1ee0853..a30c2c8d88 100755 --- a/tools/linuxfs/overlay/usr/local/bin/bannerlator-steam-shim +++ b/tools/linuxfs/overlay/usr/local/bin/bannerlator-steam-shim @@ -1,12 +1,19 @@ #!/bin/bash # `steam` on the desktop. The client writes a menu entry per installed game that runs -# `steam steam://rungameid/`, and its own launchers say `steam`; neither can run the client -# here (no dma-buf on the desktop), so on the desktop this hands off to the app for a Steam session -# in the client's desktop UI under gamescope. Anywhere else it is the client itself. +# `steam steam://rungameid/`, and its own launchers say `steam`. On the desktop that goes +# through bannerlator-steam-launch - which runs the client on the desktop itself when it draws with +# the GPU, hands the URL to a client already running there, and asks the app for a Steam session +# on a software desktop. Anywhere else it is the client itself. set -u if [ "${BL_DESKTOP:-}" = 1 ]; then url= - for arg in "$@"; do case $arg in steam://*) url=$arg ;; esac; done - exec /usr/local/bin/bannerlator-steam-launch desktop ${url:+"$url"} + ui=desktop + for arg in "$@"; do + case $arg in + steam://*) url=$arg ;; + -gamepadui|-bigpicture) ui=bigpicture ;; + esac + done + exec /usr/local/bin/bannerlator-steam-launch "$ui" ${url:+"$url"} fi exec "${HOME:-/root}/.local/share/Steam/steamrtarm64/steam" "$@"