Fix bug preventing input after the first startup of the container

Xorg was starting before udev could finish the monitor command. This prevented the X server from having access to the input devices. For some reason, any subsequent starts would be fine.

Adding a small delay to the X server start and triggering a request for device events from the kernel after a delay seems to fix this issue.
This commit is contained in:
Josh.5
2022-10-06 22:26:50 +13:00
parent 93fb8f858c
commit 54911cb97b
12 changed files with 122 additions and 36 deletions

View File

@@ -12,30 +12,28 @@
# CATCH TERM SIGNAL:
_term() {
kill -TERM "$monitor_pid" 2>/dev/null
kill -TERM "$trigger_pid" 2>/dev/null
kill -TERM "$udevd_pid" 2>/dev/null
}
trap _term SIGTERM
trap _term SIGTERM SIGINT
# EXECUTE PROCESS:
# Remove lockfile
rm -f /tmp/.udev-started
# Start udev
# Source: https://github.com/balena-io-playground/balena-base-images/
if command -v udevd &>/dev/null; then
unshare --net udevd --daemon &>/dev/null
udevd_pid=$!
else
unshare --net /lib/systemd/systemd-udevd --daemon &>/dev/null
udevd_pid=$!
fi
udevadm trigger &>/dev/null
trigger_pid=$!
# Monitor kernel uevents
udevadm monitor &
monitor_pid=$!
# Touch lockfile
sleep 1
touch /tmp/.udev-started
# Wait for 10 seconds, then request device events from the kernel
sleep 10
udevadm trigger
# WAIT FOR CHILD PROCESS:
wait "$monitor_pid"
wait "$trigger_pid"
wait "$udevd_pid"