This commit is contained in:
2026-01-09 19:45:25 +00:00
parent c8ab9afbc6
commit ec4eed38e4
2 changed files with 80 additions and 5 deletions

View File

@@ -55,6 +55,9 @@ cleanup() {
if [ -n "$VIEWER_PID" ] && kill -0 "$VIEWER_PID" 2>/dev/null; then
kill "$VIEWER_PID" 2>/dev/null || true
fi
if [ -n "$XORG_PID" ] && kill -0 "$XORG_PID" 2>/dev/null; then
kill "$XORG_PID" 2>/dev/null || true
fi
if [ -f "$PID_FILE" ]; then
PID=$(cat "$PID_FILE")
if kill -0 "$PID" 2>/dev/null; then
@@ -129,13 +132,44 @@ if [ -z "$WAYLAND_DISPLAY" ] && [ -z "$DISPLAY" ]; then
fi
fi
# Launch remote-viewer - use Xvfb if no display available
# Launch remote-viewer - use dummy X server with 3 monitors if no display available
if [ -z "$DISPLAY" ] && [ -z "$WAYLAND_DISPLAY" ]; then
echo "No display found, using Xvfb for headless SPICE client..."
# Use Xvfb with large virtual screen to support 3 monitors (5760x1080 = 3x1920x1080)
xvfb-run -a -s "-screen 0 5760x1080x24" remote-viewer spice://localhost:5930 &
echo "No display found, starting headless X server with 3 virtual monitors..."
# Find an available display number
XDISPLAY=99
while [ -S "/tmp/.X11-unix/X$XDISPLAY" ]; do
XDISPLAY=$((XDISPLAY + 1))
done
# Start Xorg with dummy driver config for 3 monitors
XORG_CONFIG="$SCRIPT_DIR/xorg-dummy.conf"
Xorg :$XDISPLAY -config "$XORG_CONFIG" -noreset +extension GLX +extension RANDR +extension RENDER &
XORG_PID=$!
sleep 2
export DISPLAY=:$XDISPLAY
# Configure 3 virtual monitors using xrandr
# Add mode to disconnected DUMMY outputs and position them
xrandr --newmode "1920x1080" 173.00 1920 2048 2248 2576 1080 1083 1088 1120 -hsync +vsync 2>/dev/null || true
# Add mode to DUMMY1 and DUMMY2, then enable them
xrandr --addmode DUMMY1 "1920x1080" 2>/dev/null || true
xrandr --addmode DUMMY2 "1920x1080" 2>/dev/null || true
# Position the outputs side by side
xrandr --output DUMMY0 --mode 1920x1080 --pos 0x0 --primary
xrandr --output DUMMY1 --mode 1920x1080 --pos 1920x0 2>/dev/null || true
xrandr --output DUMMY2 --mode 1920x1080 --pos 3840x0 2>/dev/null || true
echo "Headless X server started on :$XDISPLAY with 3 RandR monitors"
xrandr --listmonitors
# Launch remote-viewer in fullscreen to use all monitors
remote-viewer --full-screen spice://localhost:5930 &
VIEWER_PID=$!
echo "remote-viewer running headlessly under Xvfb (PID: $VIEWER_PID)"
echo "remote-viewer running headlessly (PID: $VIEWER_PID)"
else
echo "Launching remote-viewer (DISPLAY=$DISPLAY, WAYLAND_DISPLAY=$WAYLAND_DISPLAY)..."
remote-viewer spice://localhost:5930 &