Screensharing on Wayland/Sway/Niri

I’ve been able to use screen sharing on wayland before and recently it just hasn’t been working when trying on Discord (via vesktop) and even Teams via a browser (librewolf). I had both of these working before.

Here’s my configuration for screensharing:

{pkgs, ...}: {
  xdg = {
    portal = {
      enable = true;
      wlr.enable = true;
      extraPortals = [
        pkgs.xdg-desktop-portal-gtk
      ];
    };
  };
  security.rtkit.enable = true;
  services.pipewire = {
    enable = true;
    pulse.enable = true;
    alsa.enable = true;
    alsa.support32Bit = true;
    # jack.enable = true;
    # media-session.enable = true;
  };
}

I can’t seem to even find the xdg-desktop-portal-wlr.service or any portal-related services.

Anyone know what is going on?

Okay, so I can find the xdg-desktop-portal-*.services, they are just run as user services and I wasn’t passing --user to systemctl, oops.

Not showing much useful information though. I reckon I’m missing a picker for the display maybe?

Okay, I think I’ve mostly resolved this on my own with the following:

{pkgs, ...}: {
  xdg = {
    portal = {
      enable = true;
      wlr = {
        enable = true;
        settings = {
          screencast = {
            chooser_type = "simple";
            chooser_cmd = "${pkgs.slurp}/bin/slurp -f 'Monitor: %o' -or";
          };
        };
      };
      extraPortals = [
        pkgs.xdg-desktop-portal-gtk
      ];
    };
  };
  security.rtkit.enable = true;
  services.pipewire = {
    enable = true;
    pulse.enable = true;
    alsa.enable = true;
    alsa.support32Bit = true;
    # jack.enable = true;
    # media-session.enable = true;
  };
}

But I think vesktop is still not having it. OBS is working though.

Those settings might not work for every Wayland compositor. Have you seen what programs.niri does?

1 Like