Hyprland screen sharing

I had screen sharing working fine on hyprland, but then it stopped.
I tried looking through my flake, commit history to see what is could be, that have changed and found nothing.

My flake here, and in the NixOS config, I have:

  imports = [
    inputs.hyprland.nixosModules.default
  ];
  programs = {
    hyprland = {
      enable = true;
      package = inputs.hyprland.packages.${pkgs.system}.hyprland;
      xwayland.enable = true;
    };
  };

  # Set session variables
  environment = {
    variables = {
      # If cursor is not visible, try to set this to "on".
      XDG_CURRENT_DESKTOP = "Hyprland";
      XDG_SESSION_TYPE = "wayland";
      XDG_SESSION_DESKTOP = "Hyprland";
    };
    sessionVariables = {
      MOZ_ENABLE_WAYLAND = "1";
      NIXOS_OZONE_WL = "1";
      T_QPA_PLATFORM = "wayland";
      GDK_BACKEND = "wayland";
      WLR_NO_HARDWARE_CURSORS = "1";
    };
  };

  xdg.portal = {
    enable = true;
    xdgOpenUsePortal = true;
    config = {
      common.default = ["gtk"];
      hyprland.default = ["gtk" "hyprland"];
    };
    extraPortals = [
      pkgs.xdg-desktop-portal-gtk
      pkgs.xdg-desktop-portal-wlr
      pkgs.xdg-desktop-portal-hyprland
    ];
  };

I also have wireplumber and pipewire.
In my home-manager config I got:

  wayland.windowManager.hyprland = {
    enable = true;
    systemd.enable = true;
  };

  home.packages = [
    pkgs.ranger
    pkgs.pcmanfm
    pkgs.wayshot
    pkgs.sway-contrib.grimshot
    pkgs.pavucontrol
    pkgs.pulsemixer

    inputs.hyprland-contrib.packages.${pkgs.system}.grimblast
  ];

Maybe I am missing something here, which is highly likely.
But any help would be much appreciated.

I have to say, I get option to share both my entire screen and application. But they are just blank.

2 Likes

I’m having the same issue. Have you found a fix?

Yes, actually i had to use xwayland.enable = true;
When dong that, i can stream on teams and Discord, which i need for work.

Did @merrinx fix help you? I think his is only related to xwayland apps.

This week I had screen sharing break again for the xth time after update. It seems to happen quite often and is probably related to regressions introduced by incompatibilities in the desktop portal and Hyprland. I could sometimes fix it by taking different commits for those using overlays, but haven’t succeeded yet this time (only tried current master for both).

Actually I fixed it differently, I haven’t even done xwayland=true (but it seems to be true by deafult)

As I tried a lot of things, I can’t say for sure what the problem was. But it started working after I put pkgs.xdg-desktop-portal-gtk in extraPortals, here’s my config:

  xdg = {
    portal = {
      enable = true;
      xdgOpenUsePortal = true;
      config = {
        common.default = ["gtk"];
        hyprland.default = ["gtk" "hyprland"];
      };
      extraPortals = [
        pkgs.xdg-desktop-portal-gtk
        pkgs.xdg-desktop-portal-hyprland
      ];
    };
  };

At the very least you need

security.rtkit.enable = true;
services.pipewire = {
  enable = true;
  pulse.enable = true;
};

and you must ensure that the appropriate envvars are exported to the dbus/systemd user session.

Adding portals won’t really fix anything here; the hyprland portal should be taken care of by existing modules, and adding the gtk portal is irrelevant as it doesn’t provide screensharing capability (the hyprland portal is what provides that support).

Same goes for sway, though sway uses the wlr portal instead of course to provide screensharing support.

I also fail to see any relevance with enabling xwayland here, though you probably should want to enable it for other reasons.

You’re right that it’s not actually related to xwayland, or rather only if the scope described here applies, which for most won’t be the main issue.

For the rest I’m afraid it’s a bit more messy than that. Mind you, my issue was clearly a regression, i.e. it used to work with “some previous” commit of nixpkgs/nixos-unstable. The issue happened several times over months, each time without changing config. I do have (always had) the necessary basic settings enabled in my config.

Interestingly, using @gian 's portal config verbatim lead to only the gtk portal being put in $XDG_PORTAL_DIR, but only if I didn’t explicitly use the inputs.hyperland.{nixosModules,homeManagerModules}.default (which recently had been my standard, i.e. using everything hyprland from nixpkgs and not upstream.)

The Issue I’m in fact currently having is this one, which for me (at least on my intel GPU system, haven’t tried my AMD yet EDIT: on the AMD the problem does not exist this time) was not solved by the upstream fixes.

Annoyingly I couldn’t yet (easily) build, say, Hyprland v0.40.0 to test “last known good”, because pinning inputs to corresponding (older) commits gives me build failures, likely because of deps that “have moved on”, so it would require a more elaborate overlay or follows config.