Wait for Wayland session before launching kscreen-doctor

The udev rule fires the DRM "change" event during early boot, before the
user's Plasma Wayland session (and its wayland-0 socket) exists. kscreen-doctor
then cannot initialise any Qt platform plugin (Failed to create wl_display /
could not connect to display :0) and aborts, producing core dumps on every
boot — even though the script ignores its output and is otherwise fine.

Add a wait_for_wayland guard that waits up to 30s for the session socket
before touching kscreen-doctor, and skips silently if the session never
comes up (a later drm event retries once the user is logged in). The existing
flock debounce means only the first boot-time invocation waits; once the
session is ready it proceeds and applies the scale earlier than before.

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
2026-07-28 21:27:05 +02:00
co-authored by Claude
parent 0868ce16aa
commit cb2d51f5c1
2 changed files with 26 additions and 2 deletions
+6 -2
View File
@@ -75,5 +75,9 @@ Tune these variables near the top of `auto-scale-virtual.sh`:
The udev rule pins the user UID/GID (`--uid=1001 --gid=1001`) and the script
hardcodes the Plasma Wayland session env (`/run/user/1001`, `wayland-0`, etc.)
so it can reach `kscreen-doctor` even though udev starts it with an empty
environment. Update both the rule and the script's env-fallback block if your
UID or session differs.
environment. The DRM `change` event can also fire during early boot, before
the user's Wayland session (and its `wayland-0` socket) exists; the script
waits briefly for that socket and skips silently if the session never comes
up, so `kscreen-doctor` is never launched without a display to connect to (it
would otherwise abort and core-dump). Update both the rule and the script's
env-fallback block if your UID or session differs.