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?

1 Like

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

Having a similar issue, one thing was missing window/monitor picker, I’m using this to choose even single window/app:
chooser_type = “dmenu”;
chooser_cmd = “${pkgs.bemenu}/bin/bemenu --center -p "Share window:" -i -B 3”;

Right now I’m trying to figure it out why screensharing in Teams in Firefox does not work for me. Well, it does but It hangs on first image :slight_smile: . It started happen to me maybe month ago. I did not have a chance to figure out what happen.

According to nixpkgs/nixos/modules/programs/wayland/sway.nix at a0374025a863d007d98e3297f6aa46cc3141c2f0 · NixOS/nixpkgs · GitHub do’ not you need xdg-desktop-portal-wlr as well?

Right now I’m trying to figure it out why screensharing in Teams in Firefox does not work for me. Well, it does but It hangs on first image :slight_smile: . It started happen to me maybe month ago. I did not have a chance to figure out what happen.

I’ve just finish bisecting of nixpkgs and it was caused by wlr portal - ac2639c1f827b2ff76b471dfbfcc715842989793.

Downgrading version back to original version resolved issue for me, you can try the same.

  nixpkgs.overlays = [
    (final: prev: {
      xdg-desktop-portal-wlr = prev.xdg-desktop-portal-wlr.overrideAttrs (oldAttrs: {
        version = "0.8.2";
        src = oldAttrs.src.override {
          rev = "v0.8.2";
          sha256 = "sha256-HITf/hgiASWvn/z49mzS8IS1vuyXwdk1JiAOOHRSQMo=";
        };
      });
    })
  ];

edit: version v0.8.4 works as well.

Additional upstream issue/PR context:

I did, yes. I have screensharing working in Firefox on Jitsi, but for whatever reason Vesktop still doesn’t work and even Discord in the browser doesn’t work. Haven’t tried in a while though so things may have been resolved.

As an update to this thread. It seems like things are still broken.

I’ve found that the best way for me to share my screen with someone is to use Jitsi meet…