Files
Omarchy-Stream/files/headless-desktop.service
Levi Woodard 6fc34a2bd2 Add reproducible headless desktop for the X11/NVENC capture path
A Moonlight client connecting to the x11-backend host got a black screen
even though pairing, NVENC, and input injection all worked: the headless
Xorg on :0 had no window manager rendering on it, so capture=x11 grabbed
an empty black root window. (The wlr/kms backends don't hit this — their
capture source renders for itself.)

This was a hand-built path with nothing in the repo to reproduce the
desktop piece. Now:

- files/headless-desktop.service: Openbox session on :0, bound to
  xorg-headless.service, enabled via default.target for lingering boots,
  with a best-effort xsetroot so the desktop is visibly non-black.
- lib/headless.sh: capture_backend_is_x11 + install_headless_desktop
  (idempotent; pulls openbox/xsetroot via the distro dispatch).
- install.sh: installs the desktop unit when capture=x11 is detected.
- status.sh: x11 branch now FAILs if no window manager is on :0 instead
  of only checking the X server answers — the gap that hid this failure.
- docs: TROUBLESHOOTING §13 black-screen lesson; FOLLOWUPS P3 updated.

Part of the P3 x11-backend work; --backend flag, config.sh x11 variant,
and xorg-headless templates remain outstanding.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-02 23:43:00 +00:00

28 lines
1.2 KiB
Desktop File

[Unit]
Description=Openbox session on the headless Xorg (gives Sunshine something to capture)
# Without a window manager/desktop running on :0, Sunshine's x11 capture grabs
# an empty black X root window — pairing, NVENC, and input all work but the
# client sees only black. This unit renders a session onto :0 so the stream
# shows an actual desktop. Only relevant to the X11/NVENC capture backend
# (capture = x11); the wlr backend's compositor renders for itself.
Requires=xorg-headless.service
After=xorg-headless.service
PartOf=graphical-session.target
[Service]
Type=simple
Environment=DISPLAY=:0
# Wait for the X server to accept connections before launching the WM.
ExecStartPre=/bin/sh -c 'for i in $(seq 1 20); do xset -display :0 -q >/dev/null 2>&1 && exit 0; sleep 0.5; done; exit 1'
ExecStart=/usr/bin/openbox-session
# Paint a solid root so a connecting client sees an obvious (non-black) desktop.
# Leading '-' = best-effort; a missing xsetroot must not fail the unit.
ExecStartPost=-/usr/bin/xsetroot -display :0 -solid "#2e3440"
Restart=on-failure
RestartSec=2s
[Install]
# Lingering user manager reaches default.target without a graphical login,
# matching the headless-boot drop-in pattern used for Sunshine.
WantedBy=default.target