How to use Nautilus as the file picker dialog portal?

I’m currently using the Niri compositor and it uses both xdg-desktop-portal-gtk and xdg-desktop-portal-gnome. For the file dialog, it seems that the GTK one is used, instead of Nautilus. I’ve tried to configure the portal to use the correct implementation with this:

{
  xdg.portal.config.preferred."org.freedesktop.impl.portal.FileChooser" = "gnome";
}

But it doesn’t do anything. So I would like some guidance on how to achieve this.

2 Likes

A solution adapted from this github comment:

First, add the following package to your environment.systemPackages in configuration.nix (or home.packages if using Home Manager):

(runCommandLocal "nautilus-portal" { } ''
  mkdir -p $out/share/xdg-desktop-portal/portals
  cat > $out/share/xdg-desktop-portal/portals/nautilus.portal <<EOF
  [portal]
  DBusName=org.gnome.Nautilus
  Interfaces=org.freedesktop.impl.portal.FileChooser
  EOF
'')

This will create the necessary nautilus.portal file.

Then, as in that github comment, add the following to your configuration.nix (or home.nix if using Home Manager):

xdg.portal.config = {
  niri = {
    "org.freedesktop.impl.portal.FileChooser" = "nautilus";
  };
};

This is needed because the FileChooser portal of xdg-desktop-portal-gnome does not work outside of Gnome. On the other hand, Nautilus already provides the dbus org.freedesktop.impl.portal.FileChooser.

1 Like

Thanks for the answer! I’m currently back on Gnome, but it seems like a reasonable fix.

None of this should be necessary. All I had to do was install Nautilus.

For firefox I had to set widget.use-xdg-desktop-portal.file-picker to 1 in about:config, as it defaults to the portal only on flatpak builds.