Setting up xdg.portals for miracast

Hello, im trying to use miracast but i cant get it to work:
i am on hyprland trying to use gnome-networ-display, i accept suggestions for other way to enable miracasting.

    environment.systemPackages = with pkgs; [
      gnome-network-displays
      xd-desktop-portal-hyprland
    ];

    networking.firewall = {
      trustedInterfaces = [ "p2p-wl+" ];

      allowedTCPPorts = [
        7236
        7250
      ]; # wifi direct port ?
      allowedUDPPorts = [
        7236
        5353
      ];
    };

    xdg.portal = {
      enable = true;

      extraPortals = [
        pkgs.xdg-desktop-portal-gtk
        # pkgs.xdg-desktop-portal-hyprland
        pkgs.xdg-desktop-portal-gnome
        pkgs.xdg-desktop-portal-wlr
      ];

      xdgOpenUsePortal = true;
      config = {
        common = {
          default = [ "gtk" ];
          "org.freedesktop.impl.portal.Screencast" = [ "hyprland" ];
        };
      };
      # config = {
      #   # common = {
      #   #   # "org.freedesktop.impl.portal.Screenshot" = "hyprland";
      #   #   "org.freedesktop.impl.portal.Screencast" = "hyprland";
      #   #   "org.freedesktop.portal.Screencast" = "hyprland";
      #   #   default = [ "hyprland" ];
      #   # };
      #   # hyprland.default = [
      #   #   "hyprland"
      #   #   "gtk"
      #   # ];
      # };
    };

Right now i can see my display and it tries to connect but always fail after waiting.
the warning codec list not initialized
how to initialize it? is it the only problem?

hello
I think the only way to use a network display on hyprland is with wayvnc:
https://www.google.com/search?client=firefox-b-d&q=wayvnc
The setup is pretty easy and is explained in the wiki.

Then you can just connect to the display with any vnc client like gnome network display.

The Hyprland module should enable the portals out of the box according to Hyprland wiki. No need to put them to environment.systemPackages explicitly, which is not supported anyway.

If you look at the upstream issue tracker, the codec list not initialized is often a red herring. It might just be that it does not work with your device for some reason.

For debugging, you can try running env G_MESSAGES_DEBUG=all gnome-network-displays in the terminal and checking if there is some more info in the logs.

You can also try enabling the dummy sink and opening the URL using ffplay or vlc.

gnome-network-display uses XDG screen sharing portal so it should just work on Wayland. Assuming no bugs and firewall ports open.

1 Like

Yeah of course. Just recommended wayvnc since it is really easy to setup, only requiring open firewall ports, and it works really good under hyprland.