XDG portals all broken

I now get this on all DE/WMs:

xdg-open "https://nixos.wiki/"              
Error: GDBus.Error:org.freedesktop.DBus.Error.UnknownMethod: No such interface “org.freedesktop.portal.OpenURI” on object at path /org/freedesktop/portal/desktop
{ config, lib, pkgs, ... }:
let
in
{
  xdg.portal = {
    xdgOpenUsePortal = true;
    enable = true;
    # wlr.enable = true;
    # lxqt.enable = true;
    # extraPortals = [
      # pkgs.xdg-desktop-portal-gnome
      # pkgs.xdg-desktop-portal-gtk
      # pkgs.xdg-desktop-portal-hyprland
      # pkgs.xdg-desktop-portal-kde
      # pkgs.xdg-desktop-portal-wlr
    # ];
  };
}

I’ve tried just about every permutation I can think of, all extra portals included, none included, only the current desktop I’m using, or combinations I’ve seen in forum posts. e.g. with hyprland + gtk but not wlr nor gnome. Add kde in for fun, remove it, it does not matter. Under no circumstance can xdg open a link, not from the slack desktop app, not from the command line. Not under hyprland, gnome, kde, i3, sway, river. Not under wayland, and not under X11.

The error tells you what the issue is, but not why. This is why:

You are asking xdg-open to use portals to open URIs but haven’t provided a portal implementation that it can use. Naturally it will fail.

The -gtk implementation is one of the implementations that actually supports the OpenURI portal.

I quite plainly stated that I have tried with the GTK portal. Can you supply a working config?

And to be certain I have also tried the kde, lxqt, and gnome portals as well, all of which should be able to open an URL.

EDIT: here’s a fully enabled config example:

{ config, lib, pkgs, ... }:
let
in
{
  xdg.portal = {
    xdgOpenUsePortal = true;
    enable = true;
    # wlr.enable = true;
    # lxqt.enable = true;
    extraPortals = [
      pkgs.xdg-desktop-portal-gnome
      pkgs.xdg-desktop-portal-gtk
      pkgs.xdg-desktop-portal-hyprland
      pkgs.xdg-desktop-portal-kde
      pkgs.xdg-desktop-portal-wlr
    ];
  };
  environment.systemPackages = with pkgs; [ 
    xdg-desktop-portal-gnome
    xdg-desktop-portal-gtk
    xdg-desktop-portal-hyprland
    xdg-desktop-portal-kde
    xdg-desktop-portal-wlr
  ];
}

I have tried many permutations of the above as well, for example remove gtk and gnome in case they were stepping on kde’s toes. Same sort of thing with wlr and hyprland. How about just KDE? Nope. This has no effect.

Have you checked the output of systemctl --user status xdg-desktop-portal-gtk.service (or any of the other implementations)? For the sake of testing, I would suggest sticking to one DE/WM and one portal implementation. Example for Hyprland + xdg-desktop-portal-gtk:

{ pkgs, ... }:

{
  programs.hyprland.enable = true;

  xdg.portal = {
    enable = true;
    extraPortals = [ pkgs.xdg-desktop-portal-gtk ];
    xdgOpenUsePortal = true;
  };
}

Hyprland + GTK was my first attempt. And currently running on my machine:

󰰸 ➜ systemctl --user status xdg-desktop-portal-gtk.service
● xdg-desktop-portal-gtk.service - Portal service (GTK/GNOME implementation)
     Loaded: loaded (/etc/systemd/user/xdg-desktop-portal-gtk.service; linked-runtime; preset: enabled)
     Active: active (running) since Tue 2024-07-02 08:31:05 CDT; 1h 8min ago
   Main PID: 4723 (.xdg-desktop-po)
     CGroup: /user.slice/user-1000.slice/user@1000.service/app.slice/xdg-desktop-portal-gtk.service
             └─4723 /nix/store/yfbi77nfbv9bfz8c2n7p1l2xg93g8wkd-xdg-desktop-portal-gtk-1.15.1/libexec/xdg-desktop-portal-gtk

Jul 02 08:31:03 spectre360 systemd[4488]: Starting Portal service (GTK/GNOME implementation)...
Jul 02 08:31:05 spectre360 systemd[4488]: Started Portal service (GTK/GNOME implementation).
.nx on  master took 2s 
󰰸 ➜ xdg-open "https://nixos.wiki/"
Error: GDBus.Error:org.freedesktop.DBus.Error.UnknownMethod: No such interface “org.freedesktop.portal.OpenURI” on object at path /org/freedesktop/portal/desktop

Have you tried restarting the service? systemctl --user restart xdg-desktop-portal-gtk.service

I (for the most part) have all the portal things working under sway.

Specifically these lines are relevant:

Note the use of XDG_CURRENT_DESKTOP. This is used to determine if a portal is compatible with the current desktop.

There is a portal config file that can be used to provide an explicit mapping. Since my desktop is run under a gnome session I keep GNOME.

The only part I don’t have working is one of my machines does not use the dark theme for the portal. The others do use the dark theme so a bit of a mystery there.

I did give it a shot:

󰰸 ➜ systemctl --user restart xdg-desktop-portal.service
~ 
󰰸 ➜ systemctl --user status xdg-desktop-portal-gtk.service 
● xdg-desktop-portal-gtk.service - Portal service (GTK/GNOME implementation)
     Loaded: loaded (/etc/systemd/user/xdg-desktop-portal-gtk.service; linked-runtime; preset: enabled)
     Active: active (running) since Tue 2024-07-02 09:53:13 CDT; 26min ago
   Main PID: 162708 (.xdg-desktop-po)
     CGroup: /user.slice/user-1000.slice/user@1000.service/app.slice/xdg-desktop-portal-gtk.service
             └─162708 /nix/store/yfbi77nfbv9bfz8c2n7p1l2xg93g8wkd-xdg-desktop-portal-gtk-1.15.1/libexec/xdg-desktop-portal-gtk

Jul 02 10:10:44 spectre360 .xdg-desktop-po[162708]: Unable to load col-resize from the cursor theme
Jul 02 10:10:44 spectre360 .xdg-desktop-po[162708]: Unable to load col-resize from the cursor theme
Jul 02 10:10:44 spectre360 .xdg-desktop-po[162708]: Unable to load progress from the cursor theme
Jul 02 10:10:50 spectre360 .xdg-desktop-po[162708]: Unable to load col-resize from the cursor theme
Jul 02 10:10:50 spectre360 .xdg-desktop-po[162708]: Unable to load col-resize from the cursor theme
Jul 02 10:10:50 spectre360 .xdg-desktop-po[162708]: Unable to load col-resize from the cursor theme
Jul 02 10:10:50 spectre360 .xdg-desktop-po[162708]: Unable to load col-resize from the cursor theme
Jul 02 10:10:50 spectre360 .xdg-desktop-po[162708]: Unable to load col-resize from the cursor theme
Jul 02 10:10:50 spectre360 .xdg-desktop-po[162708]: Unable to load col-resize from the cursor theme
Jul 02 10:10:50 spectre360 .xdg-desktop-po[162708]: Unable to load progress from the cursor theme
~ 
󰰸 ➜ xdg-open "https://nixos.wiki/"
Error: GDBus.Error:org.freedesktop.DBus.Error.UnknownMethod: No such interface “org.freedesktop.portal.OpenURI” on object at path /org/freedesktop/portal/desktop

no luck though

thanks for the configs! I will try that out in sway directly. I did try setting some of those env vars in hyprland with no luck:

env|grep -i xdg
NIXOS_XDG_OPEN_USE_PORTAL=1
NIX_XDG_DESKTOP_PORTAL_DIR=/run/current-system/sw/share/xdg-desktop-portal/portals
XDG_BACKEND=wayland
XDG_CACHE_HOME=/home/thoth/.cache
XDG_CONFIG_DIRS=/home/thoth/.config/kdedefaults:/etc/xdg:/home/thoth/.nix-profile/etc/xdg:/home/thoth/.local/state/nix/profile/etc/xdg:/home/thoth/.local/state/nix/profile/etc/xdg:/etc/profiles/per-user/thoth/etc/xdg:/nix/var/nix/profiles/default/etc/xdg:/run/current-system/sw/etc/xdg
XDG_CONFIG_HOME=/home/thoth/.config
XDG_CURRENT_DESKTOP=Hyprland
XDG_DATA_DIRS=/nix/store/gjrpkdg5g6yn9zmbgycih5gginr0zrd4-gnome-mimeapps/share:/nix/store/0ghx9vadcdpc1g3jldrbr1f0b24gchy0-desktops/share:/home/thoth/.nix-profile/share:/home/thoth/.local/state/nix/profile/share:/home/thoth/.local/state/nix/profile/share:/etc/profiles/per-user/thoth/share:/nix/var/nix/profiles/default/share:/run/current-system/sw/share:/nix/store/hxqdl71a8jakvzxxz26rrj18va3w9mzn-gnome-shell-46.2/share/gsettings-schemas/gnome-shell-46.2:/nix/store/khhlpb4xg25faxfx5hc0cdvqqviy96kl-gnome-shell-extensions-46.2/share/gsettings-schemas/gnome-shell-extensions-46.2
XDG_DATA_HOME=/home/thoth/.local/share
XDG_RUNTIME_DIR=/run/user/1000
XDG_SEAT=seat0
XDG_SESSION_DESKTOP=hyprland
XDG_SESSION_ID=3
XDG_SESSION_TYPE=wayland
XDG_STATE_HOME=/home/thoth/.local/state

I may have too many or some insane state at this point though.

The docs on the details of how this works are… not great. Very touch with almost no indication of what goes wrong when things go wrong.

1 Like

I’d suggest you pick one portal impl, not all of them at the same time.
Also, you probably also need to run systemctl --user import-environment; presumably whatever config you’re using isn’t taking care of that for you already.

1 Like

You didn’t restart xdg-desktop-portal-gtk.service.

I did I just copied the wrong stuff, I’ll run it all again though:

󰰸 ➜ xdg-open "https://nixos.wiki/"                         
Error: GDBus.Error:org.freedesktop.DBus.Error.UnknownMethod: No such interface “org.freedesktop.portal.OpenURI” on object at path /org/freedesktop/portal/desktop
~ 
❯ systemctl --user restart xdg-desktop-portal-gtk.service
~ 
󰰸 ➜ systemctl --user restart xdg-desktop-portal.service    
~ 
󰰸 ➜ systemctl --user status xdg-desktop-portal-gtk.service
● xdg-desktop-portal-gtk.service - Portal service (GTK/GNOME implementation)
     Loaded: loaded (/etc/systemd/user/xdg-desktop-portal-gtk.service; linked-runtime; preset: enabled)
     Active: active (running) since Tue 2024-07-02 10:42:02 CDT; 10s ago
   Main PID: 242621 (.xdg-desktop-po)
     CGroup: /user.slice/user-1000.slice/user@1000.service/app.slice/xdg-desktop-portal-gtk.service
             └─242621 /nix/store/yfbi77nfbv9bfz8c2n7p1l2xg93g8wkd-xdg-desktop-portal-gtk-1.15.1/libexec/xdg-desktop-portal-gtk

Jul 02 10:42:02 spectre360 systemd[4488]: Starting Portal service (GTK/GNOME implementation)...
Jul 02 10:42:02 spectre360 systemd[4488]: Started Portal service (GTK/GNOME implementation).
~ 
󰰸 ➜ xdg-open "https://nixos.wiki/"
Error: GDBus.Error:org.freedesktop.DBus.Error.UnknownMethod: No such interface “org.freedesktop.portal.OpenURI” on object at path /org/freedesktop/portal/desktop

I just remembered that I had a portal issue a while back (I’d get a “No Apps available” message when opening a link). IDK if the solution will work for you, but try running these commands. Omit PATH if necessary:

systemctl --user import-environment PATH
systemctl --user restart xdg-desktop-portal.service
1 Like

Ah! Good point. Syncing the environment is also necessary. There is some code in my sway-gnome to do this as well.

Once i get that last problem gone I’ll try to clean it up to better communicate what is required.

Still not working, I have tried @coreyoconnor 's config directly, but maybe I am invoking it wrong? Do I need to modify gdm or sddm to do something special?

Also here are more systemctls:

󰰸 ➜ xdg-open http://joshuacox.github.io
Error: GDBus.Error:org.freedesktop.DBus.Error.UnknownMethod: No such interface “org.freedesktop.portal.OpenURI” on object at path /org/freedesktop/portal/desktop
~ 
❯ systemctl --user import-environment PATH
systemctl --user restart xdg-desktop-portal.service
~ 
󰰸 ➜ xdg-open http://joshuacox.github.io     
Error: GDBus.Error:org.freedesktop.DBus.Error.UnknownMethod: No such interface “org.freedesktop.portal.OpenURI” on object at path /org/freedesktop/portal/desktop
~ 
❯ systemctl --user import-environment PATH
systemctl --user restart xdg-desktop-portal.service
~ 
󰰸 ➜ systemctl --user status xdg-desktop-portal-gtk.service
● xdg-desktop-portal-gtk.service - Portal service (GTK/GNOME implementation)
     Loaded: loaded (/etc/systemd/user/xdg-desktop-portal-gtk.service; linked-runtime; preset: enabled)
     Active: active (running) since Wed 2024-07-03 12:20:01 CDT; 1min 50s ago
   Main PID: 6236 (.xdg-desktop-po)
     CGroup: /user.slice/user-1000.slice/user@1000.service/app.slice/xdg-desktop-portal-gtk.service
             └─6236 /nix/store/hzb2mqfishizqk3v5y2iq6allrx2r3jw-xdg-desktop-portal-gtk-1.15.1/libexec/xdg-desktop-portal-gtk

Jul 03 12:20:01 spectre360 systemd[4585]: Starting Portal service (GTK/GNOME implementation)...
Jul 03 12:20:01 spectre360 systemd[4585]: Started Portal service (GTK/GNOME implementation).
~ 
󰰸 ➜ xdg-open http://joshuacox.github.io                   
Error: GDBus.Error:org.freedesktop.DBus.Error.UnknownMethod: No such interface “org.freedesktop.portal.OpenURI” on object at path /org/freedesktop/portal/desktop

Darn! The intention with that config is for it to be enabled and “just work”. Unfortunately I don’t really know what is going on haha. Still figuring it out.

There are some arcane debugging commands I have somewhere. Checking…