Merge pull request 'Wait for Wayland session before launching kscreen-doctor' (#1) from fix/kscreen-doctor-boot-race into main
Reviewed-on: #1
This commit was merged in pull request #1.
This commit is contained in:
@@ -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
|
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.)
|
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
|
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
|
environment. The DRM `change` event can also fire during early boot, before
|
||||||
UID or session differs.
|
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.
|
||||||
|
|||||||
@@ -49,6 +49,25 @@ if ! flock -n 9; then
|
|||||||
exit 0
|
exit 0
|
||||||
fi
|
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 ---
|
# --- Read the *current* scale of the target output from kscreen-doctor JSON ---
|
||||||
get_current_scale() {
|
get_current_scale() {
|
||||||
kscreen-doctor -j 2>/dev/null \
|
kscreen-doctor -j 2>/dev/null \
|
||||||
@@ -98,6 +117,7 @@ desired_scale() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
main() {
|
main() {
|
||||||
|
wait_for_wayland || return 0
|
||||||
local res cur want
|
local res cur want
|
||||||
res="$(get_current_resolution)"
|
res="$(get_current_resolution)"
|
||||||
if [ -z "$res" ]; then
|
if [ -z "$res" ]; then
|
||||||
|
|||||||
Reference in New Issue
Block a user