Unable to share screen with Sway WM

Since this problem got a little too annoying (I was hoping it would fix itself with one of the next updates) I did a bit of digging and found a solution that worked (at least for me, using Firefox)

  1. Make sure you have xdg-desktop-portal-wlr and xdg-desktop-portal installed
  2. In $HOME/.config/sway/config, add the line include /etc/sway/config.d/*
  3. Your drop-in file /etc/sway/config.d/50-systemd-user.conf you should somewhere have the lines
exec systemctl --user import-environment DISPLAY WAYLAND_DISPLAY SWAYSOCK XDG_CURRENT_DESKTOP
exec hash dbus-update-activation-environment 2>/dev/null && \
     dbus-update-activation-environment --systemd DISPLAY WAYLAND_DISPLAY SWAYSOCK XDG_CURRENT_DESKTOP XDG_CURRENT_DESKTOP=sway
  1. Restart your computer
  2. systemctl --user show-environment should have XDG_CURRENT_DESKTOP=sway and systemctl --user status xdg-desktop-portal-wlr.service should be running.
  3. Screen sharing with Firefox (and probably most other browsers) should work now. On Firefox you can test this under https://mozilla.github.io/webrtc-landing/gum_test.html

(@joekamprad since the community editions will be deprecated, is this still worth opening a PR, adding the line from 2. to the default config?)

Relevant links:

3 Likes