← Writing

Bield · 5 min read

One desktop button, six screen servers

Bield 0.8.0 opens a machine's screen in the browser. On a Mac that's one program. On Linux it turned out to be five.

Bield 0.8.0 added a Desktop button. You click it and the machine's screen shows up in a browser tab. It looks like one feature. On Linux it's five.

I set two rules at the start. Bield doesn't capture the screen itself, because every desktop already has something that can. And opening a desktop doesn't open a port on the machine. Bield already logs in over SSH for terminals and Docker, so the screen goes through that same connection, the way ssh -L forwards a port. The browser draws it with noVNC, or with IronRDP when the server speaks RDP.

X11

On X11 the thing that can share the screen is x11vnc. Bield starts one for each desktop you open. It listens on a Unix socket inside a new /tmp/bield-desktop.XXXXXX folder that only the SSH user can open, and the moment Bield connects, it deletes the socket file. x11vnc keeps running, but nothing else can reach it anymore. That's why there's no VNC password. Nobody else can get to the socket to type one.

Two x11vnc details caught me out. -rfbport 0 should mean no TCP port at all, and it still listened on IPv6 port 5900 until I added -rfbportv6 0. And I wanted to skip the socket and run it with -inetd, speaking VNC over the SSH session's own stdin and stdout. That can't work, because sshd gives the command pipes and x11vnc hangs up on any client that isn't on a socket.

One limit you'll hit: x11vnc only opens its own user's screen. If Bield logs in as deploy and Alice is the one at the keyboard, you get nothing. Bield has to log in as alice, or as root.

Slow links

This is where most of the time went. A desktop is as slow as the slower of two hops, machine to Bield and Bield to you, and the first version sent the screen at its real size. A screen full of text on a 3000×2000 laptop is 620 to 660 KB at JPEG quality 6. At 190 KB/s that's 3.3 seconds every time the screen changes. You can't use that.

The default mode is now called Fast. x11vnc shrinks the screen to the size of your browser window before it sends anything, so half the width and half the height is a quarter of the pixels. The page also times how fast big updates arrive and turns the JPEG quality down when the link is slow, as low as 1 out of 9 under 200 KB/s. The same screen at half size and quality 2 is 135 to 154 KB, about half a second. It's blurrier, and I think that's the right default. Sharp is one click away when you need to read small text.

Macs

A Mac already ships a VNC server, Screen Sharing, so Bield installs nothing. It forwards 127.0.0.1:5900 over SSH and that's it.

The sign-in is my favourite part of the whole feature. Screen Sharing supports Apple's own login, ARD. noVNC agrees on a key with the Mac using Diffie-Hellman and encrypts your username and password with it, so Bield only ever passes encrypted bytes along. It never sees the password. Bield also offers the browser only that method, so the old 8-character VNC password never gets used, even on a Mac that allows it.

Two things I can't fix. Screen Sharing listens on port 5900 on every network interface no matter what Bield does, and it can't shrink the screen the way x11vnc can. A Mac with a big display on a slow link is just slow.

Wayland

There's no x11vnc for Wayland, and no common way to share a screen either. Each desktop does its own thing. Bield checks XDG_SESSION_TYPE with logind to find out it's on Wayland. Then it borrows WAYLAND_DISPLAY, XDG_RUNTIME_DIR and the D-Bus address from one of the user's running programs. The compositor only talks to its own user, so this only works as the user who's logged in. Root doesn't help here.

On sway, Hyprland, labwc, river and the other wlroots desktops, Bield runs wayvnc the same way it runs x11vnc, one per desktop on a private socket. It gives wayvnc an empty config and its own control socket, so your ~/.config/wayvnc/config and any wayvnc you already run are left alone.

GNOME has its own RDP server. You turn on Desktop Sharing once, and Remote Control with it, or Bield can only watch. Bield reads the login it needs with grdctl status --show-credentials. GNOME listens on 3389 on every interface and has no setting to change that, so Bield goes to 127.0.0.1:3389 over SSH like everything else.

A browser can't open a TCP connection, so for RDP the page loads IronRDP compiled to WebAssembly. That's about 6 MB the first time. RDP wants TLS, and its login is tied to the server's certificate. Bield uses IronRDP's RDCleanPath protocol for this: it does the TLS handshake in the browser's place and hands the certificate back so the login can be tied to it. Bield doesn't check the certificate. SSH already proved which machine this is.

Then KDE. Plasma 6 has KRdp, and Bield starts krdpserver for each desktop on 127.0.0.1, from port 13389 up, with a fresh self-signed certificate and a random password. KRdp only takes that password on its command line. So while the desktop is open, anyone else on the machine can read it with ps. I don't like that, and the docs say so. I've also only run it in a container with no GPU, where it got as far as logging in. If you use Plasma on real hardware, I'd really like to hear whether it works.

Servers with no screen

A VPS has no desktop to share, so Bield brings one: TigerVNC's Xvnc, IceWM, an xterm and Firefox, or Chromium if that's what's installed. It's for opening a page that only the server can reach, or a program that wants a window. It keeps running after you close the tab.

I measured it on Debian 13. Xvnc, IceWM and the terminal together take 28 to 31 MB. Firefox ESR with one Wikipedia article open takes it to 670 to 800 MB.

The details for each of these, and what the install commands do, are in the desktop docs.

Get in touch

Tell us about one of our products, or about a project you have in mind.