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:
@@ -49,6 +49,25 @@ if ! flock -n 9; then
|
||||
exit 0
|
||||
fi
|
||||
|
||||
# --- Wait for the Plasma Wayland session before touching kscreen-doctor -----
|
||||
# udev fires the drm "change" event during early boot, before this user's
|
||||
# Wayland session (and its wayland-0 socket) exists. kscreen-doctor then
|
||||
# can't initialise any Qt platform plugin and aborts, leaving core dumps
|
||||
# even though this script ignores its output. Wait briefly for the socket;
|
||||
# if the session never comes up, give up silently -- a later drm event will
|
||||
# retry once the user is logged in.
|
||||
wait_for_wayland() {
|
||||
local sock="$XDG_RUNTIME_DIR/$WAYLAND_DISPLAY"
|
||||
local waited=0
|
||||
while [ "$waited" -lt 30 ]; do
|
||||
[ -S "$sock" ] && return 0
|
||||
sleep 1
|
||||
waited=$((waited + 1))
|
||||
done
|
||||
log "Wayland socket $sock not ready after ${waited}s; skipping"
|
||||
return 1
|
||||
}
|
||||
|
||||
# --- Read the *current* scale of the target output from kscreen-doctor JSON ---
|
||||
get_current_scale() {
|
||||
kscreen-doctor -j 2>/dev/null \
|
||||
@@ -98,6 +117,7 @@ desired_scale() {
|
||||
}
|
||||
|
||||
main() {
|
||||
wait_for_wayland || return 0
|
||||
local res cur want
|
||||
res="$(get_current_resolution)"
|
||||
if [ -z "$res" ]; then
|
||||
|
||||
Reference in New Issue
Block a user