Firefox won't set as my default browser

I have version 99.0.1-1 (stable branch) on Kubuntu 22.04 (personal laptop & gaming desktop).

Even doing manually doesn’t work.

I set the about :config option widget.use-xdg-desktop-portal.file-picker to default (“2”). no dice.

There’s a bug report about this, but I’m not able to reproduce it in a Kubuntu 22.04 VM.

Can you elaborate on how you’re trying to set firefox as your default browser? Using the system settings, or in firefox’s preferences?

I just tested the latter (setting the default browser from within firefox, in about:preferences), and indeed it’s not working.

1 Like

Firefox calls xdg-settings set default-web-browser firefox_firefox.desktop, and I verified that this call works, the default XDG app is changed. However for some reason firefox isn’t able to see that the change happened, and neither is the KDE settings app.

In that Kubuntu 22.04 VM:

$ kreadconfig5 --file kdeglobals --group General --key BrowserApplication

Yet the settings application still displays Kate as my default web browser. That looks like a problem with the settings application itself?

Not in my case. Mine was already set to Firefox (can’t recall if it’s something I forced). image Firefox still seems to think it’s not the default

To check whether it’s set as the default browser, firefox issues this call:

xdg-settings check default-web-browser firefox.desktop

Which in stock Ubuntu replies “yes”, as expected. But in Kubuntu I’m seeing this:

Error org.freedesktop.DBus.Error.Failed: cannot check "default-web-browser" setting: /usr/bin/xdg-settings: 734: Bad substitution

The offending line is:

if [ x"!" == x"${browser:0:1}" ]; then

where the browser variable contains firefox_firefox.desktop, in our case.

Parameter expansion for string extraction is a bash-specific thing, but the default interpreter for /usr/bin/xdg-settings is /bin/sh (an alias to /usr/bin/dash), which indeed doesn’t do this.

And sure enough, if I change the default interpreter to /bin/bash at the top of /usr/bin/xdg-settings, the firefox snap now detects that it is the default browser.

That’s a Kubuntu-specific problem with the xdg-utils package, for which I’ve filed bug #1970594.

1 Like

Thanks for your help :cat:

It says it’s fixed, but I’m still experiencing the issue

$ kreadconfig5 --file kdeglobals --group General --key BrowserApplication
$ xdg-settings check default-web-browser firefox.desktop
/usr/bin/xdg-settings: 734: [: x!: unexpected operator

Have you used firefox to re-set it as default after you received the patched xdg-utils? if you haven’t then you need to do so for xdg-settings to correctly report that firefox is default.


Still doesn’t work if I use firefox_firefox.desktop. I still get asked.

$ kreadconfig5 --file kdeglobals --group General --key BrowserApplication
$ xdg-settings check default-web-browser firefox_firefox.desktop
/usr/bin/xdg-settings: 734: [: x!: unexpected operator

Patch your /usr/bin/xdg-settings as follows:

--- xdg-settings.orig   2022-07-29 16:47:56.186059909 +0200
+++ xdg-settings        2022-07-29 16:47:32.669780678 +0200
@@ -731,7 +731,7 @@
     # The browser may contain a relative entry to the binary starting with !
-    if [ x"!" == x"$(printf %.1s "$browser")" ]; then
+    if [ x"!" = x"$(printf %.1s "$browser")" ]; then
         # get the full path
         browser="`binary_to_desktop_file ${browser:1}`"
         binary="`desktop_file_to_binary $browser`"
@@ -1087,7 +1087,7 @@
     if [ x"$1" = "mailto" ]; then
         binary="`read_kde_config emaildefaults PROFILE_Default EmailClient`"
         # The field may contain a relative entry to the binary starting with !
-        if [ x"!" == x"$(printf %.1s "$binary")" ]; then
+        if [ x"!" = x"$(printf %.1s "$binary")" ]; then
             # get the full path
             desktop_file="`binary_to_desktop_file ${binary:1}`"
             binary="`desktop_file_to_binary $desktop_file`"

See my comment at

1 Like