Open links from flatpak via host firefox

I’m using flatpak for some applications, and have configured the xdg portal - I’m using the gtk portal. While I’m not using gnome, to my knowledge this should still work.

Whenever I open a link in a flatpak application, it instead prompts me to install an application via gnome software. According to

xdg-settings get default-web-browser

this should open with firefox.desktop.

What am I doing wrong? Is this an upstream bug? Should I be using gconf to configure the default browser? Is this a bug in our implementation of the portal configuration?

I have the same problem
I have gnome and LXQt installed, when I log into gnome, everything works
but when using LXQt and xdg-desktop-portal-kde I get the same error

A problem is definitively that the gnome portal is running
and it seems it is the one that is being used

systemctl --user status xdg-desktop-portal-gnome.service 
● xdg-desktop-portal-gnome.service - Portal service (GNOME implementation)
     Loaded: loaded (/etc/systemd/user/xdg-desktop-portal-gnome.service; static)
     Active: active (running) since Tue 2022-11-08 08:51:44 CET; 12min ago
   Main PID: 133224 (.xdg-desktop-po)
      Tasks: 9 (limit: 38414)
     Memory: 26.4M
        CPU: 220ms
     CGroup: /user.slice/user-1000.slice/user@1000.service/app.slice/xdg-desktop-portal-gnome.service
             └─133224 /nix/store/bhavkr6x64i9dxi7z1ka2n86m6hisma6-xdg-desktop-portal-gnome-43.1/libexec/xdg-desktop-portal-gnome

Nov 08 08:51:44 desktop systemd[1749]: Starting Portal service (GNOME implementation)...
Nov 08 08:51:44 desktop systemd[1749]: Started Portal service (GNOME implementation).
Nov 08 08:51:44 desktop .xdg-desktop-po[133224]: Unhandled parent window type 
Nov 08 08:51:44 desktop .xdg-desktop-po[133224]: Failed to associate portal window with parent window

If you set xdg.portal.gtkUsePortal, all gtk applications will use the portal instead of native applications.

I’m unsure if this applies to lxqt as well. You’re saying the portal works when you’re using GNOME?

Yes and it seems gtkUsePortal doesn’t have any effect

ok, could get it to work
with the instructions from this issue

I would not really recommend that, it is buggy and will be removed in 22.11.

1 Like

Yes, I was suggesting that as a potential reason for why all applications are suddenly using the portal when they shouldn’t, I misunderstood that as “I’d like lxqt to stop using the portal for its file chooser”.

In retrospect, obviously lxqt is a desktop and not an application, it was probably late ;p

Hrm, I’m still struggling to get this to work. What exactly did you change, just this:

  systemd.user.extraConfig = ''

I’ve been running with home-manager for a while, which already does a systemd-import. I’ve added PATH to the list to try that out too: home-manager/xsession.nix at bc90de24d898655542589237cc0a6ada7564cb6c · nix-community/home-manager · GitHub

Other debugging suggestions from the issue look right, I can launch firefox using gio, and firefox is visible in systemd-run:

tlater ~ $ systemd-run --user --pipe gio mime x-scheme-handler/https
Running as unit: run-u69.service
Default application for “x-scheme-handler/https”: firefox.desktop
Registered applications:
Recommended applications:

However, opening firefox via systemd-run fails without errors:

tlater ~ $ systemd-run --user -P gio open
Running as unit: run-u78.service
# Nothing happens, return controls to shell

Curiously, I had a chromium installed with flatpak previously (to use MS teams, which now supports firefox). I did manage to open a link in it, which previously did not work. Just still not in my host’s firefox - possibly related to it being installed with home-manager?

Yep, that seems to be it, installed Firefox with environment.systemPackages and it just works now. Any idea why my home-manager profile is not playing ball? I have no idea how to further debug this.

I suppose this would be something to raise on that upstream if not.

On the day I said I’ve fixed it
I only ran systemctl --user import-environment PATH and systemctl --user restart xdg-desktop-portal-gnome.service xdg-desktop-portal.service
and added this config (and thought with this, all is fixed)

systemd.user.extraConfig = ''

but after the next boot, applications using the portal always used epiphany as default browser :sweat_smile:

now I’ve just added the 2 systemctl --user scripts to the lxqt autostart scripts :see_no_evil:

1 Like

I just had a similar problem with Plex Desktop.

Running these two commands made it work:

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

Feels a bit hacky to just add it to the start up script.