Skip to content

Instantly share code, notes, and snippets.

@b401
Created February 19, 2022 13:09
Show Gist options
  • Save b401/67c2177f585f4216ad8ca134e0675bbf to your computer and use it in GitHub Desktop.
Save b401/67c2177f585f4216ad8ca134e0675bbf to your computer and use it in GitHub Desktop.
Screensharing on wayland with NixOS
# rtkit for pipewire
security.rtkit.enable = true;

# enable pipewire with wlr support
services.pipewire.enable = true;
xdg = {
  portal = {
    enable = true;
    extraPortals = with pkgs; [
      # wlroots specific
      # use xdg-desktop-portal-gtk for gnome.
      xdg-desktop-portal-wlr
    ];
    # uncomment for gnome
    # gtkUsePortal = true;
  };
};

xdg.portal.wlr.settings = {
  screencast = {
    # set the output_name (this doesn't really matter)
	  output_name = "HDMI-A";
	  max_fps = 60;
	  chooser_type = "simple";
	  chooser_cmd = "${pkgs.slurp}/bin/slurp -f %o -or";		
  };
};

Make sure to install slurp which is used as a helper to choose the screen which should be shared.

You can test the screensharing on https://mozilla.github.io/webrtc-landing/gum_test.html

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment