Clicked links in desktop apps not opening browers

Does xdg-open https://example.com/ do something sensible or does it just error out (or worse: fail silently)?

yeah, I am installing it with the flake…

# SNIP
hyprland.url = "github:hyprwm/Hyprland";

# SNIP - Home Manager Import
hyprland.homeManagerModules.default

So are you are saying to not install that package if I have installed it via a flake?

This might be part of the problem. That command does not exist on my system. I may have erroneously assumed that it would be bundled in with the hyprland specific package.

OK this was the solution. I had to install xdg-utils.

I’m wondering if I’m missing any other XDG related packages?

1 Like

yes thats in the flake xdg should be installed no need to install the package how ever u maybe need.

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

im not sure if i do infact need to enable wlr and have it. but i do need gtk. forgot for what exactly.

my understanding of wlr - the hyperland version was a fork that added the hyprland specifics. I will try the other settings

I definitely had to install it. :man_shrugging:

Thats weird its mentioned in the wiki that if u use the flake you dont need to install it. can you check if the system is running it.

systemctl --user status xdg-desktop-portal-hyprland.service 

It is. :+1:


λ systemctl --user status xdg-desktop-portal-hyprland.service 
● xdg-desktop-portal-hyprland.service - Portal service (Hyprland implementat>
     Loaded: loaded (/etc/systemd/user/xdg-desktop-portal-hyprland.service; >
     Active: active (running) since Thu 2023-06-15 23:29:44 PDT; 8h ago

But I also added your previous code already.

yeah I did notice that aswell it doesnt seem to have a path in terminal for the portal but the system is running it. I noticed that I had multiple xdg-hyprland when I was trying to locate it. its why i commented it out in that code. I dont remember why i needed the gtk one but it was something similar to links in apps.

dont forget to garbage collect before locating it drove me crazy hahaha.

I believe with the gtk portal links in apps should work now

They started working once I installed xdg-utils. But I added these other config suggestions to mitigate future xdg-related misbehaviour.

Thank you to all who helped!

Glad I could help! just a quick note if u used the config and in the future had problems with screen sharing for example chromecast screen or web to tv try to disable wlr portal. I didnt have the time to test it with wlr enabled. goodluck!

1 Like

My only screen shank scenario is simply zoom. Ha ha ha but thank you so much for the heads up.

As I understand the portals, from reading various docs. For hyprland on NixOS the portals should be xdg-desktop-portal-gtk and xdg-desktop-portal-hyprland.

xdg-desktop-portal-hyprland is a fork of xdg-desktop-portal-wlr. I’d still expect partial functionality with wlr.

The only real documentation is on the Arch linux wiki (but of course) and this useful fact buried in there:

When a request is made, xdg-desktop-portal will use the XDG_CURRENT_DESKTOP environment variable to determine which backend it will use for the request. If more than one backend can be used for the current desktop, the first one in alphabetical order is chosen. If no backend for the current desktop can handle the interface, no backend is available for the current desktop, or xdg-desktop-portal can’t determine the current desktop, then it will choose the first portal in alphabetical order between all of the installed portals that support the requested interface.

( XDG Desktop Portal - ArchWiki )

Which explained to me how having both installed worked at all.

2 Likes

For me, xdg-open is not working, and having xdg-utils installed does not do the trick.

I sniffed around the nixpkgs patches for xdg-utils a bit, and it turns out in unstable, it patches xdg-utils such that it unconditionally sets the DE to “flatpak” when

NIXOS_XDG_OPEN_USE_PORTAL=1

for me this broke xdg-open completely, always complaining that there was no application found. Unsetting NIXOS_XDG_OPEN_USE_PORTAL fixed it for me, but now I’m wondering if this is the right choice moving forward.

Could I fix the flatpak route for xdg-open instead in my config perhaps? I forked @nomadics nix config here: GitHub - Arroquw/nixos-config: My NixOS Flake + dotfiles

the flatpak route calls this command:

gdbus call --session --dest org.freedesktop.portal.Desktop --object-path /org/freedesktop/portal/desktop --method org.freedesktop.portal.OpenURI.OpenURI --timeout 5 "" "https://google.com" {}

(I added google.com as simple test). For me, this prints

(objectpath '/org/freedesktop/portal/desktop/request/1_578/t',)

and then the screen with “no application found” pops up.

So, unset NIXOS_XDG_OPEN_USE_PORTAL, or fix it in a different way? It does seem to work fine with my DE set to gnome (even though I don’t have gnome installed, though I do have gio), while using hyprland.

2 Likes

Sorry for the delete and double post, I was jumping to the wrong conclusions.

I’m running into this issue: Flatpak apps can't launch the default browser · Issue #189851 · NixOS/nixpkgs · GitHub

Simply running

systemctl --user import-enviroment PATH

Fixes it for me. I guess I will watch the github issue, and in the meantime run this command in my hyprland.conf or something like that.

Adding this to Hyprland init script solved the issue for me:

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

With your help @justinvson-pd and this blogpost i was able to solve it with

xdg.portal.config.common.default = [ "*" ];

in the nixos-config

EDIT: After a bit of trial and error i found a more fine-grained solution:

xdg.portal.config.common.default = [ "gnome" ];
3 Likes

As @brnix mentioned installing xdg-utils instantly resolved my exact issue using hyprland aswell, real lifesaver.