fix: a game with a launch-option picker is no longer closed while the picker is open (MK11) (#1869)

fix: a game with a launch-option picker is no longer closed while the picker is open
This commit is contained in:
MaxsTechReview authored and GitHub committed 2026-10-30 18:16:11 -04:00
1 parent 484afffffd
commit 7e47db2e2a
4 files changed
+58 -15

No files matched your search

@@ -111,10 +111,7 @@ object AutoComponents {
@VisibleForTesting internal var gameRunning: () -> Boolean = { gameProcessRunning() }
private fun gameProcessRunning(): Boolean = File("/proc").listFiles()?.any { p ->
p.name.all(Char::isDigit) && runCatching { String(File(p, "cmdline").readBytes()).replace('\u0000', ' ') }.getOrNull()
?.let { it.contains("SteamLaunch AppId=") || it.contains("proton waitforexitandrun") } == true
} == true
private fun gameProcessRunning(): Boolean = com.droiddeck.launcher.session.SteamGameProcess.running()
fun queueInSession(context: Context, game: Library.SteamGame) {
if (appKey(game) == null) return
@@ -1339,17 +1339,7 @@ class SessionService : Service() {
/** A Steam game is running: the client runs each one under its reaper, and Proton's script
* waits on the game with waitforexitandrun. Read from the command lines, as ComponentsManager does. */
private fun steamGameRunning(): Boolean {
val procs = File("/proc").listFiles() ?: return false
for (p in procs) {
if (!p.name.all(Char::isDigit)) continue
val cmd = runCatching { File(p, "cmdline").readBytes() }.getOrNull() ?: continue
if (cmd.isEmpty()) continue
val text = String(cmd).replace('\u0000', ' ')
if (text.contains("SteamLaunch AppId=") || text.contains("waitforexitandrun")) return true
}
return false
}
private fun steamGameRunning(): Boolean = SteamGameProcess.running()
private fun resumeSession(panelVisible: Boolean = true) {
if (SessionState.suspended) SessionState.resumeRequested = true
@@ -0,0 +1,18 @@
package com.droiddeck.launcher.session
import java.io.File
object SteamGameProcess {
fun matches(cmdline: ByteArray): Boolean {
val args = String(cmdline).split('\u0000')
for (i in args.indices) {
if (args[i] == "waitforexitandrun") return true
if (args[i] == "SteamLaunch" && args.getOrNull(i + 1)?.startsWith("AppId=") == true) return true
}
return false
}
fun running(proc: File = File("/proc")): Boolean = proc.listFiles()?.any { p ->
p.name.all(Char::isDigit) && runCatching { File(p, "cmdline").readBytes() }.getOrNull()?.let(::matches) == true
} == true
}
@@ -0,0 +1,38 @@
package com.droiddeck.launcher.session
import org.junit.Assert.assertFalse
import org.junit.Assert.assertTrue
import org.junit.Rule
import org.junit.Test
import org.junit.rules.TemporaryFolder
import java.io.File
class SteamGameProcessTest {
@get:Rule val tmp = TemporaryFolder()
private fun cmdline(vararg args: String) = args.joinToString("\u0000", postfix = "\u0000").toByteArray()
@Test fun theSessionsOwnSearchesAreNotAGame() {
assertFalse(SteamGameProcess.matches(cmdline("pgrep", "-a", "-f", "SteamLaunch AppId=[0-9]")))
assertFalse(SteamGameProcess.matches(cmdline("pgrep", "-f", "reaper SteamLaunch")))
assertFalse(SteamGameProcess.matches(cmdline("pgrep", "-f", "reaper SteamLaunch AppId=976310( |$)")))
assertFalse(SteamGameProcess.matches(cmdline("sh", "-c", "pgrep -f 'proton waitforexitandrun'")))
assertFalse(SteamGameProcess.matches(cmdline("/usr/bin/steam", "steam://rungameid/976310")))
}
@Test fun steamsReaperAndProtonAreAGame() {
assertTrue(SteamGameProcess.matches(cmdline("/root/.local/share/Steam/steamrtarm64/reaper", "SteamLaunch", "AppId=976310", "--",
"/root/.local/share/Steam/compatibilitytools.d/droiddeck-proton-arm64/proton", "waitforexitandrun", "MK11.exe")))
assertTrue(SteamGameProcess.matches(cmdline("python3", "/proton", "waitforexitandrun", "game.exe")))
}
@Test fun runningLooksAtEveryProcess() {
val proc = tmp.newFolder("proc")
fun process(pid: String, vararg args: String) = File(proc, pid).apply { mkdirs() }.resolve("cmdline").writeBytes(cmdline(*args))
process("100", "pgrep", "-a", "-f", "SteamLaunch AppId=[0-9]")
process("self", "reaper", "SteamLaunch", "AppId=1")
assertFalse(SteamGameProcess.running(proc))
process("200", "reaper", "SteamLaunch", "AppId=976310", "--", "proton", "waitforexitandrun", "MK11.exe")
assertTrue(SteamGameProcess.running(proc))
}
}