Default browser not used from within Snap?

I’m experiencing the same issue with notable. links are openned in firefox when my default browser is brave.

executing xdg-open on my host open links properly in brave.

notable snap is using the classic confinment

Same for me. I’ve used Telegram snap and it opens all links in FF. Just reinstalled native telegram. Now I’ve installed Spotify and same here, links are opening in FF.

xdg-open useses Chrome.

Perhaps issue is because my current DE is KDE but I do have Gnome installed, but I have no idea what is default browser there, coz I don’t use Gnome. Perhaps Snap uses settings from gnome, not from current WM.

Can a root cause be pinpointed?

I guess that it’s due to the nature of snaps trying to sandbox apps, and due to that invoking xdg-open/similar with the wrong env vars, causing it to create a separate browser profile.

As this issue seems quite widespread, I hope we can work together to get this fixed!

2 Likes

I’m using Kubuntu 21.04 and what has helped me is to set default browser in KDE settings, instead of relying on Chrome’s setting of default browser.
Under System Settings > Applications > Default Applications > Web Browser
Now all links in snap apps are opening in Chrome.

I am using Kubuntu 21.04 and am having this same problem. I have my default browser set to Brave everywhere (system settings, xdg-settings get default-web-browser, xdg-settings get default-url-scheme-handler https and xdg-settings get default-url-scheme-handler http. When I click on a link from a Snap application, it opens Chrome.

KDE uses its own non-standard system for default web browser, while flatpak/snap applications use portals that use only XDG spec via glib. Here’s an XDG spec-friendly way to set default browser (with firefox as example):
xdg-mime default firefox.desktop x-scheme-handler/http
xdg-mime default firefox.desktop x-scheme-handler/https

Apparently, someone should talk to KDE folks that they should finally standardize their extensions or stop using them, that mime incompatiblity across DEs is really annoying.

2 Likes

I’m also seeing this behavior on Gnome 40.5.0. My default browser is set to Chrome, but our Electron-based classic confinement snap opens external links in Firefox. xdg-open <url> opens Chrome. All of the following return google-chrome.desktop:

xdg-settings get default-web-browser
xdg-settings get default-url-scheme-handler http
xdg-settings get default-url-scheme-handler https
xdg-mime query default x-scheme-handler/http
xdg-mime query default x-scheme-handler/https

The Electron app is opening the browser like this (which apparently delegates to xdg-open on Linux Electron builds):

import {shell} from 'electron';
shell.openExternal(url);

Interestingly this only occurs when the app is built with classic confinement. When the app is built with strict confinement the same code opens Chrome (although for other reasons we unfortunately need to use classic). I’ve also seen this behavior across multiple distros including my Gentoo laptop and a Ubuntu VM. Any other ideas for workarounds?

Check gio mime x-scheme-handler/http, gio mime x-scheme-handler/https and gio open. It uses the same library portals are using to find default handler.

2 Likes

Thanks for the suggestions @ilya-fedin. I just checked the gio settings, and they all appear to be defaulting to Chrome as well, although Firefox is listed first under Recommended applications. Executing either gio open 'http://example.com' or gio open 'https://example.com' both launch Chrome.

$ gio mime x-scheme-handler/http
Default application for “x-scheme-handler/http”: google-chrome.desktop
Registered applications:
	firefox.desktop
	links-links-2.desktop
	org.gnome.Epiphany.desktop
Recommended applications:
	firefox.desktop
	links-links-2.desktop
	org.gnome.Epiphany.desktop

$ gio mime x-scheme-handler/https
Default application for “x-scheme-handler/https”: google-chrome.desktop
Registered applications:
	firefox.desktop
	links-links-2.desktop
	org.gnome.Epiphany.desktop
Recommended applications:
	firefox.desktop
	links-links-2.desktop
	org.gnome.Epiphany.desktop

Check whether flatpak permissions has desktop-used-apps for http/https, that would be preferred if xdg-desktop-portal version is less than 1.8.0

1 Like

OK I tried flatpak permissions, flatpak permission-list, and flatpak permission-list xdg-desktop-portal, but none of these returned any output (I’m not very familiar with flatpak though, so I might have gotten something wrong with the commands there).

As far as system packages, and I have xdg-desktop-portal v1.10.1 and xdg-desktop-portal-gtk v1.8.0

Oh, I re-read your post and found this. Apparently, these apps don’t use portals and don’t read your MIME associations due to some wrappers that redefine $HOME for them.

1 Like

I have the same issue on Kubuntu 20.04 with two different apps: Telegram and JetBrains WebStorm. They were installed one without --classic and another one with it. Now whenever I try to open an URL from them, they open Firefox, while the default browser is set to Chrome (in KDE System Settings and as well in xdg-open)

Only gio shows it’s Firefox, however I don’t get how Gnome might by related, as this is KDE.

So… after 2 years, does have any solution to this weird problem?

Portals are using glib, so snap apps will use whatever gio gives you

Ah, will they! Interesting. So the question now is how to update these settings. I.e. how to set the correct values to gio mime. I’m gonna google for it and post a feedback. And it’s gonna be the final answer, not yet provided.

gio is an implementation of the XDG standard, so you can use commands from Default browser not used from within Snap?.

1 Like

Oh, thank you!

So the answer to this question was given in that comment! And this worked for me:

xdg-mime default google-chrome.desktop x-scheme-handler/http
xdg-mime default google-chrome.desktop x-scheme-handler/https

But it’s a little strange as:

xdg-mime query default x-scheme-handler/http

returned google-chrome.desktop even before.

Anyways, I marked your comment with “heart” and it’s just the second one, while it’s actually THE answer and should be appreciated.

Thanks.

xdg-utils call DE’s executables for commands and KDE’s one check whether queried mimetype is x-scheme-handler/http(s) and returns the value from KDE’s non-standard config rather than real mimetype association according to the XDG spec. xdg-utils is a collection of heavy bugged shell scripts.

2 Likes

Thanks. Indeed it shows firefox for me. How do I change gio settings?

This helped. Thanks Ilya.

$ gio mime x-scheme-handler/https google-chrome.desktop
Set google-chrome.desktop as the default for x-scheme-handler/https
$ gio mime x-scheme-handler/http google-chrome.desktop
Set google-chrome.desktop as the default for x-scheme-handler/http