Jun 08, 2020
A workaround to share screen on sway with vnc
Sway[1] on Wayland[2] on Archlinux[3] is my current setup for my laptop, with which I mostly code, for work or for fun.
Sway is a great wm to use, but it’s maturing and something is not natively available yet.
One of those things that I was missing is a way to share your screen during web meetings, with chromium, which, on my laptop, runs with XWayland, the X11 compatibility layer.
[1] https://swaywm.org/
[2] https://wayland.freedesktop.org/
[3] https://www.archlinux.org/
wayvnc
wayvnc[1] is a software that implements a vnc server for Wayland.
I stumbled across it after reading a workaround for screen sharing in a Sway github issue[2]. A user was proposing to use x11docker to run slack in a container and wayvnc on the host.
Starting from that I looked for wayvnc and get a working setup on my Archlinux machine.
I just installed aml-git[3], neatvnc-git[4] and wayvnc-git[5] from AUR.
Then you can run wayvnc 0.0.0.0
to start the vnc server.
[1] https://github.com/any1/wayvnc/
[2] https://github.com/swaywm/sway/issues/5083#issuecomment-599979314
[3] https://aur.archlinux.org/packages/aml-git/
[4] https://aur.archlinux.org/packages/neatvnc-git/
[5] https://aur.archlinux.org/packages/wayvnc-git/
Sharing the screen with chromium
I usually use qutebrowser[6] to browse the web (try it, it’s awesome), but for web meetings on Microsoft Teams, Zoom, or Whereby I still use chromium due to the fact that it seems more well supported by those services.
On my laptop chromium runs with the wayland-x11 compatibility layer. For me that means that when I try to share my screen in a web meeting I can select for sharing only the windows from applications running with the x11 backend. If I share the entire screen I get a pith black windows with nothing in it.
To do the trick I start remmina[7] prepended with GDK_BACKEND=x11
.
That will run remmina with the x11 compatibility layer.
Once launched I can connect with remmina VNC client to localhost
and get a window that shows my screen.
Because that window is on the x11 layer it is detected by chromium and I can share that in the web meeting.