diff --git a/app/src/main/java/com/droiddeck/launcher/MainActivity.kt b/app/src/main/java/com/droiddeck/launcher/MainActivity.kt index 825cecdc3b..c7b253dd75 100644 --- a/app/src/main/java/com/droiddeck/launcher/MainActivity.kt +++ b/app/src/main/java/com/droiddeck/launcher/MainActivity.kt @@ -272,8 +272,11 @@ class MainActivity : ComponentActivity() { ), FrontEndActions( onPlay = { startSession(Intent(this, SessionActivity::class.java)) }, + // Steam's desktop client as a window on the desktop: under gamescope the + // client puts itself into Big Picture whatever it is started with. onPlayDesktopUi = { startSession(Intent(this, SessionActivity::class.java) + .putExtra(SessionService.EXTRA_MODE, SessionService.MODE_DESKTOP) .putExtra(SessionService.EXTRA_STEAM_UI, "desktop")) }, onSteamGame = { g -> diff --git a/app/src/main/java/com/droiddeck/launcher/session/SessionFiles.kt b/app/src/main/java/com/droiddeck/launcher/session/SessionFiles.kt index 37d937a48c..5cd53d1b6f 100644 --- a/app/src/main/java/com/droiddeck/launcher/session/SessionFiles.kt +++ b/app/src/main/java/com/droiddeck/launcher/session/SessionFiles.kt @@ -43,6 +43,8 @@ object SessionFiles { // the three under /usr/bin, all no-ops that answer "nothing to do" (see each file). "usr/bin/steamos-update" to "usr/bin/steamos-update", "usr/bin/steamos-select-branch" to "usr/bin/steamos-select-branch", + // Big Picture's "Switch to Desktop": asks the app for the desktop with Steam in it. + "usr/bin/steamos-session-select" to "usr/bin/steamos-session-select", "usr/bin/jupiter-biosupdate" to "usr/bin/jupiter-biosupdate", "usr/bin/steamos-polkit-helpers/steamos-priv-write" to "usr/bin/steamos-polkit-helpers/steamos-priv-write", "usr/bin/steamos-polkit-helpers/steamos-set-timezone" to "usr/bin/steamos-polkit-helpers/steamos-set-timezone", 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 11b87b05b2..b7a759838f 100644 --- a/app/src/main/java/com/droiddeck/launcher/session/SessionService.kt +++ b/app/src/main/java/com/droiddeck/launcher/session/SessionService.kt @@ -469,6 +469,9 @@ class SessionService : Service() { // The second library's name, for bannerlator-steam-library; the bind itself is made below. GameStorage.effective(this)?.let { guest.add("BL_LIBRARY_LABEL=" + it.label.replace('"', ' ')) } if (SessionState.mode == MODE_STEAM && SessionState.steamUi == "desktop") guest.add("BL_STEAM_UI=desktop") + // The desktop asked for with Steam in it (the front end's "Steam Desktop UI", Big Picture's + // "Switch to Desktop"): the desktop's autostart opens the client's desktop UI there. + if (SessionState.mode == MODE_DESKTOP && SessionState.steamUi == "desktop") guest.add("BL_DESKTOP_STEAM=1") val shellGuest = ArrayList(guest).apply { add("SHELL=/bin/bash") add("TERM=xterm-256color") @@ -734,6 +737,8 @@ class SessionService : Service() { * The desktop's Steam launchers cannot start the client where they are (no dma-buf on the * desktop), so they leave `steam-launch` in the session directory instead: which UI, and a * steam:// URL or nothing. This ends the session and hands the activity the one to start. + * `session=desktop` (Big Picture's "Switch to Desktop", steamos-session-select) asks for the + * desktop instead, with Steam's desktop client started in it. */ private var launchWatcher: android.os.FileObserver? = null @@ -748,15 +753,18 @@ class SessionService : Service() { file.delete() var ui = "desktop" var url = "" + var session = MODE_STEAM text.lineSequence().forEach { line -> when { line.startsWith("ui=") -> ui = line.removePrefix("ui=").trim() line.startsWith("url=") -> url = line.removePrefix("url=").trim() + line.startsWith("session=") && line.removePrefix("session=").trim() == "desktop" -> session = MODE_DESKTOP } } - Log.i(TAG, "launch request from the session: Steam $ui" + (if (url.isNotEmpty()) " $url" else "")) + Log.i(TAG, "launch request from the session: " + (if (session == MODE_DESKTOP) "the desktop with " else "") + + "Steam $ui" + (if (url.isNotEmpty()) " $url" else "")) val next = Intent(this@SessionService, com.droiddeck.launcher.SessionActivity::class.java) - .putExtra(EXTRA_MODE, MODE_STEAM) + .putExtra(EXTRA_MODE, session) .putExtra(EXTRA_STEAM_UI, ui) .addFlags(Intent.FLAG_ACTIVITY_NEW_TASK) if (url.isNotEmpty()) next.putExtra(EXTRA_STEAM_URL, url) @@ -1048,7 +1056,8 @@ class SessionService : Service() { const val EXTRA_PROGRAM = "program" /** MODE_RUN: arguments after the program (a game to boot). */ const val EXTRA_PROGRAM_ARGS = "programArgs" - /** MODE_STEAM: "desktop" for the client's desktop UI (default Big Picture); a steam:// URL to hand it. */ + /** MODE_STEAM: "desktop" for the client's desktop UI (default Big Picture); a steam:// URL to hand it. + * MODE_DESKTOP: "desktop" = open Steam's desktop client in the desktop once it is up. */ const val EXTRA_STEAM_UI = "steamUi" const val EXTRA_STEAM_URL = "steamUrl" diff --git a/tools/linuxfs/desktop/autostart b/tools/linuxfs/desktop/autostart index 3aa88e9061..b28f23535c 100644 --- a/tools/linuxfs/desktop/autostart +++ b/tools/linuxfs/desktop/autostart @@ -36,6 +36,10 @@ swaybg -m fill -i /usr/share/backgrounds/steamdeck.png & run pcmanfm-qt pcmanfm-qt --desktop --profile lxqt run lxqt-panel lxqt-panel /usr/lib/xdg-desktop-portal-wlr >/dev/null 2>&1 & +# The desktop was asked for with Steam in it (the front end's "Steam Desktop UI", Big Picture's +# "Switch to Desktop"): the client's desktop UI, as the menu's Steam entry opens it. A running +# client just gets the request; on a software desktop it goes back to the app as a Steam session. +[ "${BL_DESKTOP_STEAM:-0}" = 1 ] && run steam /usr/local/bin/bannerlator-steam-launch desktop # Remote runs, for driving the desktop from a debugger: with ~/.droiddeck-remote-run present (only # the app or root can create it), each script dropped into ~/.cache/droiddeck/run/ is run once, # inside the session with its environment, its output tagged into the desktop log. diff --git a/tools/linuxfs/overlay/usr/bin/steamos-session-select b/tools/linuxfs/overlay/usr/bin/steamos-session-select new file mode 100644 index 0000000000..30141e79fc --- /dev/null +++ b/tools/linuxfs/overlay/usr/bin/steamos-session-select @@ -0,0 +1,18 @@ +#!/bin/sh +# The SteamOS session switch. Big Picture's power menu runs it for "Switch to Desktop" (a Plasma +# session: "plasma", "plasma-wayland-persistent", ...) and waits for Game Mode to end; with nothing +# here it sat on "Switching to Desktop..." for ever. Here the desktop is DroidDeck's own: the app is +# asked for a desktop session with Steam's desktop client open in it (the request file +# bannerlator-steam-launch uses; the app ends this session and starts that one). Anything else - +# "gamescope", the session Game Mode already is - has nothing to do. +echo "steamos-session-select: $*" >&2 +case "${1:-}" in + ""|gamescope) exit 0 ;; +esac +dir=${BL_LAUNCH_DIR:-} +if [ -z "$dir" ] || [ ! -d "$dir" ]; then + echo "steamos-session-select: not inside a DroidDeck session (BL_LAUNCH_DIR unset)" >&2 + exit 1 +fi +printf 'session=desktop\nui=desktop\nurl=\n' > "$dir/steam-launch.tmp" && mv -f "$dir/steam-launch.tmp" "$dir/steam-launch" +exit 0