====== Screen sharing in wlroots compositors ====== This is a guide on how to achieve screen sharing under any wlroots based compositor that runs on %%FreeBSD%%. This does not apply to other wayland client implementations. ===== Dbus ===== To get the portals working, we need to have dbus enabled. First of all, install dbus from either ports or binary repositories: # pkg install dbus Enable the service and start it # service dbus enable # service dbus start Verify it is running correctly: dbus-monitor signal time=1644778417.267818 sender=org.freedesktop.DBus -> destination=:1.230 serial=2 path=/org/freedesktop/DBus; interface=org.freedesktop.DBus; member=NameAcquired string ":1.230" signal time=1644778417.267897 sender=org.freedesktop.DBus -> destination=:1.230 serial=4 path=/org/freedesktop/DBus; interface=org.freedesktop.DBus; member=NameLost string ":1.230" ===== Launching compositor with dbus ===== It's required to launch the respective compositor using a dbus session. If it is started with an alias/command, it's enough to prepend dbus-launch to the exec command, like so: dbus-launch wayfire Otherwise, in case it is started via a Display Manager like ly or gdm, it's enough to edit the respective compositor's .desktop file under /usr/local/share/wayland-sessions/ : vi /usr/local/share/wayland-sessions/wayfire.desktop [Desktop Entry] Name=Wayfire Exec=dbus-launch wayfire TryExec=wayfire Icon= Type=Application DesktopNames=Wayfire ===== Pipewire ===== Installing pipewire is mandatory: pkg install multimedia/pipewire ===== XDG portals ===== We require two xdg desktop portals, deskutils/xdg-desktop-portal and x11/xdg-desktop-portal-wlr. xdg-desktop-portal is not available via the binary repositories at the time of this writing, so it is required to build it from the ports system. # cd /usr/ports/multimedia/xdg-desktop-portal # make install Also as of the time of this writing, this port is marked as broken due to an unmatched feature in open(2). However, such feature is present in 13 STABLE. xdg-desktop-portal-wlr is easily installable with pkg: # pkg install xdg-desktop-portal-wlr ===== Environment variables ===== The following env vars ought to be present and correctly defined in order for screen sharing to work: | VARIABLE | VALUE | | XDG_CURRENT_DESKTOP | wayfire/sway... | | WAYLAND_DISPLAY | wayland-1 (auto set by DM/seatd) | ===== Starting the portals ===== We need three processes running: 1. pipewire -v 2. /usr/local/libexec/xdg-desktop-portal -v -r 3. /usr/local/libexec/xdg-desktop-portal-wlr -l DEBUG ===== Testing ===== It is possible to test if screen sharing is working under firefox by visiting the gUM test page; [[https://mozilla.github.io/webrtc-landing/gum_test.html|gUM Test Page]].