(Partial) Wayland WebRTC Screenshare Fix
Using VNC to Workaround Pipewire Woes
For some time now, various screen capturing functionalities have worked very smoothly on Wayland. Take screenshots for example: grim works very nicely and when used in conjunction with slurp, it can select any region the user wants. Likewise with screenrecording, courtesy of obs-studio with the wlrobs plugin (there are other plugins for other desktops like GNOME). One sore area thus far in my experience has been getting WebRTC screensharing working. This affects applications such as Jitsi and Discord.
Purportedly, all you need to run is pipewire, xdg-desktop-portal, and the accompanying plugin for your desktop (xdg-desktop-portal-wlr for me). Despite this and despite both having tried setting environment variables accordingly and running xdg-desktop-portal and xdg-desktop-portal-wlr, I haven’t gotten screensharing working on Chromium or Firefox. Luckily, I’ve found a novel workaround for getting screensharing working.
The Steps
You’ll need Chromium installed for this. It is irrelevant whether or not you run it natively or with Xwayland. After that, we’re going to download wayvnc. This is a lightweight, wayland
compliant VNC server. After it’s installed, run wayvnc -r -o <desired-output-here-if-you-have-more-than-one>
. We’re going to need a VNC client to view our desktop with. We’re going to
use noVNC, which is a VNC client that runs in the browser. To fetch and launch it, we’re going to run the following commands:
git clone https://github.com/novnc/noVNC.git && cd noVNC
./utils/launch.sh --vnc localhost:5900
Now, open Chromium and launch http://localhost:6080/vnc.html. Click on the gear for settings. Click on “View Only” and deselect “Shared Mode”. We also want to enable local scaling so that the entire screen is being recorded. Now this is where the magic happens: Chromium has the extremely useful feature of being able to share tabs in the screenshare dialog. Navigate to whatever WebRTC web app you’re using and enable screensharing. Click on the noVNC tab. Congratulations!, you’re now sharing your desktop in real time without the need to fuss with pipewire and the xdg-desktop-portal stuff.
The Slight Catch
In my usage, I’ve only been able to get real time track in the workspace that Chromium is open in. If I switch workspaces, it’ll show that workspace, but the output will be frozen until I switch back to the workspace with Chromium. I will post an update if I figure out how to rectify this issue.