Skip to content

Share a wlroots session's real screen (851-4500) - #1507

Merged
pondorasti merged 4 commits into
mainfrom
alexandru/851-4500-linux-desktop-step-8b-share-a-wlroots
Nov 27, 2026
Merged

pondorasti merged 4 commits into
mainfrom
alexandru/851-4500-linux-desktop-step-8b-share-a-wlroots

Conversation

@pondorasti

@pondorasti pondorasti commented Nov 27, 2026 •

Copy link
Copy Markdown
Member

Linear: 851-4500, step 8b of the Linux desktop (851-4479).

What changes

  • The Screen display now also shares the server account's Sway, Hyprland or other wlroots session (sway, Hyprland, river, labwc, wayfire), with the same rules as the X11 screen: a private socket (codevisor-screen-<hex>.sock, mode 0600, no TCP port), the same relay, only the account at the screen, never the login screen, the viewing notification, and no prompt at the machine.
  • The helper is wayvnc, run with --config=/dev/null (a user config can't add a TCP port or a password), --render-cursor, under umask 077, with its control socket next to the VNC socket when the installed wayvnc has one.
  • GNOME and KDE on Wayland are still refused in one sentence, and nothing is installed for them.
  • setup --screen installs exactly the programs that are missing (apt, dnf, pacman, zypper). For a session at the screen, that means its own helper. With nobody at the screen, it means the helpers for every kind of session the machine offers, so a Sway-only machine gets wayvnc and never x0vncserver.
  • Which session kind: the compositor is the account's process that holds the display's lock file open ($XDG_RUNTIME_DIR/<WAYLAND_DISPLAY>.lock). Wayland processes go first only when logind says Wayland, and that filter runs before the session-bus preference. A nested display (its compositor started inside another Wayland display) is left out.
  • A wayvnc older than 0.5 by --version (Ubuntu 22.04's 0.4.1, which has no --unix-socket) isn't started. It's named as too old instead.

Why wayvnc and not w0vncserver

TigerVNC 1.16's w0vncserver shares through the desktop portal's RemoteDesktop and ScreenCast interfaces, which ask the person at the screen. In a Fedora container, w0vncserver 1.16.2 exited without a session bus, and also exited on a bus without the portal. wayvnc uses wlroots' own protocols and never prompts. So wayvnc is used, even when both are installed.

Proof

  • Headless Sway in an OrbStack VM (Ubuntu 24.04) on the final code, a Sway-only machine (no X sessions, no Xorg), logged in through LightDM with a real logind session (Type=wayland):
    • With nobody logged in, setup --screen installed only wayvnc; x0vncserver stayed absent.
    • After login, the server started wayvnc on a private socket. Its control socket was also private, and nothing listened on TCP. The apps were offered Desktop and Screen.
    • The newest process in the session had no SWAYSOCK, and the server still called the session wlroots: Sway held wayland-1.lock.
  • A scripted viewer connected through the relay. Text typed through it appeared in alice's terminal, and the notification showed.
  • Another account (bob) was refused while alice was at the screen.
  • swaymsg exit with a viewer connected: the relay closed, the helper and socket were gone, and only Desktop was offered.
  • Debian 12's wayvnc 0.5 (no control socket) ran with the same flags under a headless Sway in a container: a private socket, an RFB answer, and no TCP.
  • Ubuntu 22.04 ships wayvnc 0.4.1, which has no --unix-socket. Checked in a container.
  • Screenshots are on the Linear ticket.
  • Unit tests cover the wayvnc command, the kind of the session (compositor in the session, or with no logind an ancestor; XWayland-only apps ignored), refusals, and installs.

Not done

  • Hyprland wasn't run. It is covered by unit tests only. It isn't wlroots-based any more, but it supports the wlr screencopy and virtual-input protocols that wayvnc needs.
  • No test with a real GNOME, KDE, labwc or river session. Unit tests cover the lock-file lookup for them.
  • On wlroots only the first output is shared.

🤖 Generated with Claude Code

pondorasti and others added 4 commits November 26, 2026 21:35
The Screen display now also shares the account's Sway, Hyprland or other
wlroots session, through wayvnc on the same private socket and relay as the
X11 screen. GNOME and KDE on Wayland are still refused in one sentence.

wayvnc rather than w0vncserver: w0vncserver goes through the desktop
portal, which asks the person at the screen, and exits without it.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Review fixes: an app started for XWayland alone no longer makes a Sway
session look unshareable; without logind a compositor counts only when it
started the session's process; the helper is recognised only by its socket
flag; installing refuses a GNOME or KDE Wayland session; the CLI shows a
Wayland display given as a path; the README says wlroots shares one output
and that Debian 12's wayvnc has no control socket.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
… its display (851-4500)

Second review of #1507:
- With nobody at the screen, the helpers wanted are those for the kinds of
  session the machine offers (X11 sessions or Xorg; an installed wlroots
  compositor), and installs are exactly the missing programs, so a Sway
  machine never gets or is refused over x0vncserver.
- Wayland processes go first only when logind says Wayland, and before the
  preference for the session bus.
- A Wayland session is wlroots when the compositor behind the chosen
  process's WAYLAND_DISPLAY is one, found by walking up its parents, so a
  nested Sway doesn't mark GNOME as wlroots, and /proc isn't scanned.
- A wayvnc without --unix-socket (Ubuntu 22.04's 0.4.1) is named as too
  old instead of being started.
- A refused Wayland session reports nothing missing, asks no sudo, and
  keeps its display; wayvnc --help runs only when wlroots needs it; the
  CLI's session names are a Map.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…e by its version (851-4500)

Code review of the second-round fixes:
- The compositor of a Wayland display is the process of the account that
  holds `<runtime dir>/<WAYLAND_DISPLAY>.lock` open, not a parent of the
  chosen app: labwc and river detach their apps, and a parent whose
  environment can't be read no longer ends the search. A display whose
  compositor was started inside another Wayland display is nested and
  left out, so a Sway window in GNOME is never shared. Found compositors
  are remembered while they run.
- wayvnc is too old only when --version names a version below 0.5; a
  failing --help or --version no longer blocks sharing.
- With nobody at the screen, an old wayvnc refuses setup only when no
  other kind the machine offers can be shared.
- Checking the programs again also checks the machine's session kinds.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@pondorasti
pondorasti merged commit ee4cace into main Nov 27, 2026
@pondorasti
pondorasti deleted the alexandru/851-4500-linux-desktop-step-8b-share-a-wlroots branch November 27, 2026 06:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant