fix(session): clear X display locks a killed session left so games get the display Steam names

When a session is force-stopped, its /tmp/.X<n>-lock files stay behind. If the pid recorded in a
lock now belongs to another process, wlroots counts the display as taken and gamescope moves its
game Xwayland past it (:0 and :2). Steam then gives games :1, where no server answers. Wine's
display drivers fail, explorer.exe cannot start, and the game never opens a window. The /tmp sweep
now also removes these locks when no X server, gamescope or KWin is running.
This commit is contained in:
The412Banner committed 2026-11-29 12:03:50 +00:00
1 parent a847ae5f39
commit fe40b1a0f3
2 files changed
+16 -5

No files matched your search

@@ -116,7 +116,7 @@ prepare_locale() {
clear_stale_tmp() {
local running names=() n
running=$(pgrep -af 'steamwebhelper|steamrtarm64/steam|steamrt64/steam|--type=|droiddeck-appimage-run|dbus-run-session|dbus-daemon.*--session|dbus-launch|kwin|plasmashell' 2>/dev/null)
running=$(pgrep -af 'steamwebhelper|steamrtarm64/steam|steamrt64/steam|--type=|droiddeck-appimage-run|dbus-run-session|dbus-daemon.*--session|dbus-launch|kwin|plasmashell|Xwayland|Xorg|Xvfb|Xvnc|gamescope' 2>/dev/null)
case $running in
*steamwebhelper* | *steamrtarm64/steam* | *steamrt64/steam*) ;;
*) names+=(-o -name 'mangohud.????????' -o -name '.com.valvesoftware.Steam.??????'
@@ -132,6 +132,10 @@ clear_stale_tmp() {
*kwin* | *plasmashell*) ;;
*) names+=(-o \( -type d -empty -name 'plasma-csd-generator.??????' \)) ;;
esac
case $running in
*kwin* | *Xwayland* | *Xorg* | *Xvfb* | *Xvnc* | *gamescope*) ;;
*) names+=(-o \( -type f -name '.X[0-9]*-lock' \)) ;;
esac
[ ${#names[@]} -gt 0 ] || return 0
n=$(find /tmp -mindepth 1 -maxdepth 1 \( "${names[@]:1}" \) -print -exec rm -rf {} + 2>/dev/null | wc -l)
[ "$n" -gt 0 ] && echo "== /tmp: cleared $n entries earlier sessions left"
+11 -4
View File
@@ -14,10 +14,11 @@ CHROMIUM = ["scoped_dir3yu9Xt/SingletonSocket"]
APPIMAGE = ["droiddeck-appimage.19PoOD"]
BUS = ["dbus-1zWfOP1IaR="]
KDE = ["plasma-csd-generator.BVWIWA/"]
STALE = STEAM + CHROMIUM + APPIMAGE + BUS + KDE
XLOCK = [".X0-lock", ".X1-lock"]
STALE = STEAM + CHROMIUM + APPIMAGE + BUS + KDE + XLOCK
KEPT = ["droiddeck-mangohud.conf", ".X11-unix/", "steamworks", "steamABCDEF/inside", "notes.txt",
"mangohud.conf", ".wine-10480/", "dbus-1zWfOP1IaR.log", "dbus-notasocket",
"plasma-csd-generator.CQGZSw/kept"]
"plasma-csd-generator.CQGZSw/kept", ".X11-unix/X1", ".Xauthority"]
def sweep_function(tmp):
@@ -57,7 +58,7 @@ class SessionTmpTest(unittest.TestCase):
return os.path.lexists(self.tmp / name.rstrip("=").split("/")[0])
def test_what_killed_sessions_left_goes_and_nothing_else(self):
self.assertEqual("== /tmp: cleared 8 entries earlier sessions left\n", self.sweep())
self.assertEqual("== /tmp: cleared 10 entries earlier sessions left\n", self.sweep())
for name in STALE:
self.assertFalse(self.exists(name), name)
for name in KEPT:
@@ -84,7 +85,13 @@ class SessionTmpTest(unittest.TestCase):
self.kept_while("55 dbus-daemon --config-file=/usr/local/share/droiddeck/system-bus.conf --nofork\n", [])
def test_a_running_desktop_keeps_its_decorations(self):
self.kept_while("44 kwin_wayland --xwayland\n", KDE)
self.kept_while("44 kwin_wayland --xwayland\n", KDE + XLOCK)
def test_a_running_x_server_keeps_its_display_lock(self):
self.kept_while("33 /usr/bin/Xwayland :1 -rootless -core -listenfd 41\n", XLOCK)
def test_a_running_gamescope_keeps_its_display_locks(self):
self.kept_while("22 gamescope --backend wayland --xwayland-count 2 -- droiddeck-session steam\n", XLOCK)
def test_a_clean_tmp_says_nothing(self):
self.sweep()