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:
25
overlay/usr/bin/common-functions.sh
Executable file
25
overlay/usr/bin/common-functions.sh
Executable file
@@ -0,0 +1,25 @@
|
||||
#!/usr/bin/env bash
|
||||
###
|
||||
# File: common-functions.sh
|
||||
# Project: bin
|
||||
# File Created: Tuesday, 6th October 2022 9:30:00 pm
|
||||
# Author: Josh.5 (jsunnex@gmail.com)
|
||||
# -----
|
||||
# Last Modified: Tuesday, 6th October 2022 9:30:00 pm
|
||||
# Modified By: Josh.5 (jsunnex@gmail.com)
|
||||
###
|
||||
|
||||
wait_for_x() {
|
||||
# Wait for X server to start
|
||||
# (Credit: https://gist.github.com/tullmann/476cc71169295d5c3fe6)
|
||||
MAX=60 # About 30 seconds
|
||||
CT=0
|
||||
while ! xdpyinfo >/dev/null 2>&1; do
|
||||
sleep 0.50s
|
||||
CT=$(( CT + 1 ))
|
||||
if [ "$CT" -ge "$MAX" ]; then
|
||||
LOG "FATAL: $0: Gave up waiting for X server $DISPLAY"
|
||||
exit 11
|
||||
fi
|
||||
done
|
||||
}
|
||||
@@ -8,15 +8,14 @@
|
||||
# Last Modified: Wednesday, 26th January 2022 5:38:23 pm
|
||||
# Modified By: Console and webGui login account (jsunnex@gmail.com)
|
||||
###
|
||||
#
|
||||
# I made this wrapper script so that I could easily try a range of desktop environments
|
||||
#
|
||||
|
||||
source /usr/bin/common-functions.sh
|
||||
|
||||
# CATCH TERM SIGNAL:
|
||||
_term() {
|
||||
kill -TERM "$desktop_pid" 2>/dev/null
|
||||
}
|
||||
trap _term SIGTERM
|
||||
trap _term SIGTERM SIGINT
|
||||
|
||||
|
||||
# CONFIGURE:
|
||||
@@ -31,6 +30,8 @@ ln -sf /usr/share/backgrounds/steam.jpg /etc/alternatives/desktop-background
|
||||
|
||||
|
||||
# EXECUTE PROCESS:
|
||||
# Wait for the X server to start
|
||||
wait_for_x
|
||||
# Run the desktop environment in order of priority
|
||||
if [[ -e /usr/bin/cinnamon-session ]]; then
|
||||
/usr/bin/cinnamon-session --display=${DISPLAY} &
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
_term() {
|
||||
kill -TERM "$pulseaudio_pid" 2>/dev/null
|
||||
}
|
||||
trap _term SIGTERM
|
||||
trap _term SIGTERM SIGINT
|
||||
|
||||
|
||||
# EXECUTE PROCESS:
|
||||
|
||||
@@ -9,11 +9,13 @@
|
||||
# Modified By: Josh.5 (jsunnex@gmail.com)
|
||||
###
|
||||
|
||||
source /usr/bin/common-functions.sh
|
||||
|
||||
# CATCH TERM SIGNAL:
|
||||
_term() {
|
||||
kill -TERM "$sunshine_pid" 2>/dev/null
|
||||
}
|
||||
trap _term SIGTERM
|
||||
trap _term SIGTERM SIGINT
|
||||
|
||||
|
||||
# CONFIGURE:
|
||||
@@ -25,18 +27,9 @@ fi
|
||||
|
||||
|
||||
# EXECUTE PROCESS:
|
||||
# Wait for X server to start
|
||||
# (Credit: https://gist.github.com/tullmann/476cc71169295d5c3fe6)
|
||||
MAX=60 # About 30 seconds
|
||||
CT=0
|
||||
while ! xdpyinfo >/dev/null 2>&1; do
|
||||
sleep 0.50s
|
||||
CT=$(( CT + 1 ))
|
||||
if [ "$CT" -ge "$MAX" ]; then
|
||||
LOG "FATAL: $0: Gave up waiting for X server $DISPLAY"
|
||||
exit 11
|
||||
fi
|
||||
done
|
||||
# Wait for the X server to start
|
||||
wait_for_x
|
||||
# Start the sunshine server
|
||||
sunshine min_log_level=info /home/${USER}/sunshine/sunshine.conf &
|
||||
sunshine_pid=$!
|
||||
|
||||
|
||||
@@ -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"
|
||||
|
||||
30
overlay/usr/bin/start-x11vnc.sh
Executable file
30
overlay/usr/bin/start-x11vnc.sh
Executable file
@@ -0,0 +1,30 @@
|
||||
#!/usr/bin/env bash
|
||||
###
|
||||
# File: start-x11vnc.sh
|
||||
# Project: bin
|
||||
# File Created: Tuesday, 6th October 2022 9:30:00 pm
|
||||
# Author: Josh.5 (jsunnex@gmail.com)
|
||||
# -----
|
||||
# Last Modified: Tuesday, 6th October 2022 9:30:00 pm
|
||||
# Modified By: Josh.5 (jsunnex@gmail.com)
|
||||
###
|
||||
|
||||
source /usr/bin/common-functions.sh
|
||||
|
||||
# CATCH TERM SIGNAL:
|
||||
_term() {
|
||||
kill -TERM "$x11vnc_pid" 2>/dev/null
|
||||
}
|
||||
trap _term SIGTERM SIGINT
|
||||
|
||||
|
||||
# EXECUTE PROCESS:
|
||||
# Wait for the X server to start
|
||||
wait_for_x
|
||||
# Start the x11vnc server
|
||||
/usr/bin/x11vnc -display ${DISPLAY} -rfbport ${PORT_VNC} -shared -forever&
|
||||
x11vnc_pid=$!
|
||||
|
||||
|
||||
# WAIT FOR CHILD PROCESS:
|
||||
wait "$x11vnc_pid"
|
||||
37
overlay/usr/bin/start-xorg.sh
Executable file
37
overlay/usr/bin/start-xorg.sh
Executable file
@@ -0,0 +1,37 @@
|
||||
#!/usr/bin/env bash
|
||||
###
|
||||
# File: start-xorg.sh
|
||||
# Project: bin
|
||||
# File Created: Tuesday, 11th January 2022 8:28:52 pm
|
||||
# Author: Josh.5 (jsunnex@gmail.com)
|
||||
# -----
|
||||
# Last Modified: Friday, 6th October 2022 9:21:00 pm
|
||||
# Modified By: Josh.5 (jsunnex@gmail.com)
|
||||
###
|
||||
|
||||
# CATCH TERM SIGNAL:
|
||||
_term() {
|
||||
kill -TERM "$xorg_pid" 2>/dev/null
|
||||
}
|
||||
trap _term SIGTERM SIGINT
|
||||
|
||||
|
||||
# EXECUTE PROCESS:
|
||||
# Wait for udev
|
||||
MAX=10
|
||||
CT=0
|
||||
while [ ! -f /tmp/.udev-started ]; do
|
||||
sleep 1
|
||||
CT=$(( CT + 1 ))
|
||||
if [ "$CT" -ge "$MAX" ]; then
|
||||
LOG "FATAL: $0: Gave up waiting for udev server to start"
|
||||
exit 11
|
||||
fi
|
||||
done
|
||||
# Run X server
|
||||
/usr/bin/Xorg -ac -noreset -novtswitch -sharevts -dpi "${DISPLAY_DPI}" +extension "GLX" +extension "RANDR" +extension "RENDER" vt7 "${DISPLAY}" &
|
||||
xorg_pid=$!
|
||||
|
||||
|
||||
# WAIT FOR CHILD PROCESS:
|
||||
wait "$xorg_pid"
|
||||
Reference in New Issue
Block a user