Desktop installs the runtime and the desktop on a fresh install, on the loading screen

Desktop is enabled without a runtime or the desktop package. The session's loading screen installs
whatever is missing first - the runtime, then the desktop ("downloading the desktop · 212 of 426
MB", checking, unpacking) - and starts the session when both are in. A failure ends on the loading
screen with the reason. Desktop UI and Desktop now give the same non-Adreno warning as Play before
any download.
This commit is contained in:
The412Banner committed 2026-09-23 12:53:36 -04:00
1 parent 2b5aae9100
commit 0ea4b584b4
3 files changed
+57 -32

No files matched your search

@@ -203,14 +203,9 @@ class MainActivity : ComponentActivity() {
theme = theme,
),
FrontEndActions(
onPlay = {
// No runtime and not an Adreno: the same warning Setup gives, before any download.
val warn = installed == null && !com.steamdeck.launcher.core.DeviceSupport.adreno()
if (warn && available != null) showNonAdreno = available
else startActivity(Intent(this, SessionActivity::class.java))
},
onPlay = { startSession(Intent(this, SessionActivity::class.java)) },
onPlayDesktopUi = {
startActivity(Intent(this, SessionActivity::class.java)
startSession(Intent(this, SessionActivity::class.java)
.putExtra(SessionService.EXTRA_STEAM_UI, "desktop"))
},
onSteamGame = { g ->
@@ -218,7 +213,7 @@ class MainActivity : ComponentActivity() {
.putExtra(SessionService.EXTRA_STEAM_URL, "steam://rungameid/${g.gameId}"))
},
onDesktop = {
startActivity(Intent(this, SessionActivity::class.java)
startSession(Intent(this, SessionActivity::class.java)
.putExtra(SessionService.EXTRA_MODE, SessionService.MODE_DESKTOP))
},
onEmulator = { e -> launchProgram(e.program) },
@@ -693,6 +688,13 @@ class MainActivity : ComponentActivity() {
install(release)
}
/** Starts a session; with no runtime on a non-Adreno, the same warning Setup gives comes first, before any download. */
private fun startSession(intent: Intent) {
val warn = installed == null && !com.steamdeck.launcher.core.DeviceSupport.adreno()
if (warn && available != null) showNonAdreno = available
else startActivity(intent)
}
private fun install(release: LinuxRuntimeInstaller.Release) {
busy = true
failed = false
@@ -140,7 +140,12 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback {
surfaceView.pointerIcon = noCursor
loading = LoadingState(this)
if (!SessionState.running && com.steamdeck.launcher.runtime.LinuxRuntimeInstaller.installedVersion(this) == null) installRuntimeThenStart()
if (!SessionState.running) {
val needRuntime = com.steamdeck.launcher.runtime.LinuxRuntimeInstaller.installedVersion(this) == null
val needDesktop = intent.getStringExtra(SessionService.EXTRA_MODE) == SessionService.MODE_DESKTOP &&
!com.steamdeck.launcher.runtime.DesktopCatalog.desktopInstalled(this)
if (needRuntime || needDesktop) installThenStart(needRuntime, needDesktop)
}
hud = PerfHud(this)
hud.onPresentingWindowChanged = {
if (FrameGen.engine(this) != FrameGen.ENGINE_OFF) CompositorHost.rearmFrameGen { applyFrameGen() }
@@ -255,37 +260,23 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback {
// ── Compositor ──────────────────────────────────────────────────────────────────────────
/** True while the loading screen is installing the Linux runtime; the session waits for it. */
/** True while the loading screen is installing the Linux runtime or the desktop; the session waits for it. */
@Volatile private var installingRuntime = false
/**
* First Play on a fresh install: the runtime is downloaded and unpacked here, on the loading
* screen's own line and bar, and the session starts when it is in. Nothing else changes.
* First Play (or Desktop) on a fresh install: the runtime, and for the desktop its package,
* are downloaded and unpacked here, on the loading screen's own line and bar, and the session
* starts when they are in. Nothing else changes.
*/
private fun installRuntimeThenStart() {
private fun installThenStart(runtime: Boolean, desktop: Boolean) {
installingRuntime = true
loading.step = "downloading the Linux runtime"
loading.step = if (runtime) "downloading the Linux runtime" else "downloading the desktop"
loading.percent = -1
Thread({
val release = com.steamdeck.launcher.runtime.LinuxRuntimeInstaller.fetchRelease()
val mb = release?.let { it.size / 1_000_000 } ?: 0L
val ok = release != null && com.steamdeck.launcher.runtime.LinuxRuntimeInstaller.install(this, release) { stage, p ->
uiHandler.post {
loading.percent = p
loading.step = when (stage) {
"Downloading" -> if (p >= 0 && mb > 0) "downloading the Linux runtime · ${p * mb / 100} of $mb MB" else "downloading the Linux runtime"
"Verifying" -> "checking the Linux runtime"
else -> "unpacking the Linux runtime"
}
}
}
val problem = (if (runtime) installRuntime() else null) ?: (if (desktop) installDesktop() else null)
uiHandler.post {
installingRuntime = false
if (!ok) {
loading.showEnded(if (release == null) "Could not reach the runtime catalog. Check the connection and press Play again."
else "The Linux runtime did not install. Check the connection and press Play again.")
return@post
}
if (problem != null) { loading.showEnded(problem); return@post }
loading.percent = -1
loading.step = "Starting the session…"
// The surface may have come and gone while the download ran; start on the live one.
@@ -294,6 +285,37 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback {
}, "runtime-install").start()
}
/** Reports one package's download on the loading screen: "<what> · 332 of 791 MB", checking, unpacking. */
private fun progressFor(what: String, mb: Long) = com.steamdeck.launcher.runtime.LinuxRuntimeInstaller.ProgressListener { stage, p ->
uiHandler.post {
loading.percent = p
loading.step = when {
stage.startsWith("Downloading") -> if (p >= 0 && mb > 0) "downloading $what · ${p * mb / 100} of $mb MB" else "downloading $what"
stage.startsWith("Verifying") -> "checking $what"
else -> "unpacking $what"
}
}
}
/** Null when the runtime is in, else the loading screen's closing line. */
private fun installRuntime(): String? {
val release = com.steamdeck.launcher.runtime.LinuxRuntimeInstaller.fetchRelease()
?: return "Could not reach the runtime catalog. Check the connection and press Play again."
val ok = com.steamdeck.launcher.runtime.LinuxRuntimeInstaller.install(this, release,
progressFor("the Linux runtime", release.size / 1_000_000))
return if (ok) null else "The Linux runtime did not install. Check the connection and press Play again."
}
/** Null when the desktop package is in, else the loading screen's closing line. */
private fun installDesktop(): String? {
uiHandler.post { loading.percent = -1; loading.step = "downloading the desktop" }
val entry = com.steamdeck.launcher.runtime.DesktopCatalog.fetch()?.firstOrNull { it.id == "desktop" }
?: return "Could not reach the desktop catalog. Check the connection and press Desktop again."
val problem = com.steamdeck.launcher.runtime.DesktopCatalog.install(this, entry,
progressFor("the desktop", entry.size / 1_000_000))
return problem?.let { "The desktop did not install ($it). Check the connection and press Desktop again." }
}
override fun surfaceCreated(holder: SurfaceHolder) {
if (installingRuntime) return
val runtimeDir = File(filesDir, ".wayland-rt").apply { mkdirs() }
@@ -589,7 +589,8 @@ private fun Content(s: FrontEndState, selected: String, a: FrontEndActions, modi
Rise(0) { Eyebrow("Desktop") }
Rise(3) {
Actions {
PrimaryButton("Desktop", enabled = s.ready && !s.busy && s.desktopInstalled, onClick = a.onDesktop)
// Enabled without a runtime or the desktop: the session's loading screen installs them first.
PrimaryButton("Desktop", enabled = !s.busy, onClick = a.onDesktop)
SecondaryButton("Desktop & apps", onClick = a.onApps)
Cog(a.onDesktopSettings)
}