0

I am running Kubuntu 20.04 with KDE Plasma. I have recently switched from Google Chrome to the Brave Browser, version (taken from brave://settings/help) 1.34.81 Chromium: 97.0.4692.99 (Official Build) (64-bit), installed from the Brave repos.

I have set my default browser as Brave in the KDE options. xdg-open, however, keeps opening URLS with Chrome.

Whenever I open the KDE default application settings, this is the settings I see, as if it did not manage to set the default, no matter if I used the "following application" or "following command" setting: enter image description here

Additional things I tried:

  • sensible-browser and x-www-browser both correctly open Brave, not Chrome. Only xdg-open opens Chrome.
  • XDG_UTILS_DEBUG_LEVEL=2 xdg-mime query default text/html returns:
Running KDE trader query "text/html" mimetype and "Application" servicetype
google-chrome.desktop
  • XDG_UTILS_DEBUG_LEVEL=2 xdg-mime default brave-browser.desktop text/html returns (error code 0):
make_default_kde: No kde runtime detected
make_default_generic brave-browser.desktop text/html
Updating /home/adriano/.config/mimeapps.list
  • XDG_UTILS_DEBUG_LEVEL=2 xdg-settings set default-web-browser brave-browser.desktop returns (with error code 4: the action failed, according to the manual):
Running KDE trader query "text/html" mimetype and "Application" servicetype
make_default_kde: No kde runtime detected
make_default_generic brave-browser.desktop text/html
Updating /home/adriano/.config/mimeapps.list
Running KDE trader query "text/html" mimetype and "Application" servicetype
make_default_kde: No kde runtime detected
make_default_generic google-chrome.desktop text/html
Updating /home/adriano/.config/mimeapps.list
  • sudo XDG_UTILS_DEBUG_LEVEL=2 xdg-settings set default-web-browser brave-browser.desktop returns (with error code 0):
Checking /root/.config/mimeapps.list
make_default_kde: No kde runtime detected
make_default_generic brave-browser.desktop text/html
Updating /root/.config/mimeapps.list
Checking /root/.config/mimeapps.list
Checking /root/.config/mimeapps.list
make_default_kde: No kde runtime detected
make_default_generic brave-browser.desktop x-scheme-handler/http
Updating /root/.config/mimeapps.list
Checking /root/.config/mimeapps.list
Checking /root/.config/mimeapps.list
make_default_kde: No kde runtime detected
make_default_generic brave-browser.desktop x-scheme-handler/https
Updating /root/.config/mimeapps.list
Checking /root/.config/mimeapps.list
Checking /root/.config/mimeapps.list
make_default_kde: No kde runtime detected
make_default_generic brave-browser.desktop x-scheme-handler/about
Updating /root/.config/mimeapps.list
Checking /root/.config/mimeapps.list
Checking /root/.config/mimeapps.list
make_default_kde: No kde runtime detected
make_default_generic brave-browser.desktop x-scheme-handler/unknown
Updating /root/.config/mimeapps.list
Checking /root/.config/mimeapps.list
  • The Chrome and Brave desktop files are OK. In fact, they are almost identical. This is the output of diff /usr/share/applications/google-chrome.desktop /usr/share/applications/brave-browser.desktop:
3c3
< Name=Google Chrome
---
> Name=Brave Web Browser
108c108
< Exec=/usr/bin/google-chrome-stable %U
---
> Exec=/usr/bin/brave-browser-stable %U
111c111
< Icon=google-chrome
---
> Icon=brave-browser
114c114
< MimeType=application/pdf;application/rdf+xml;application/rss+xml;application/xhtml+xml;application/xhtml_xml;application/xml;image/gif;image/jpeg;image/png;image/webp;text/html;text/xml;x-scheme-handler/http;x-scheme-handler/https;
---
> MimeType=application/pdf;application/rdf+xml;application/rss+xml;application/xhtml+xml;application/xhtml_xml;application/xml;image/gif;image/jpeg;image/png;image/webp;text/html;text/xml;x-scheme-handler/http;x-scheme-handler/https;x-scheme-handler/ipfs;x-scheme-handler/ipns;
169c169
< Exec=/usr/bin/google-chrome-stable
---
> Exec=/usr/bin/brave-browser-stable
221c221
< Exec=/usr/bin/google-chrome-stable --incognito
---
> Exec=/usr/bin/brave-browser-stable --incognito
  • This is the output of grep html ~/.config/mimeapps.list (only brave is listed):
application/xhtml+xml=brave-browser.desktop;brave-browser.desktop;code.desktop;org.kde.kate.desktop;libreoffice-writer.desktop;okularApplication_txt.desktop;vim.desktop;firefox.desktop;
text/html=brave-browser.desktop;code.desktop;firefox.desktop;org.kde.kate.desktop;libreoffice-writer.desktop;rstudio.desktop;okularApplication_txt.desktop;vim.desktop;
application/xhtml+xml=brave-browser.desktop;
text/html=brave-browser.desktop
  • manually editing ~/.config/mimeapps.list and /usr/share/applications/defaults.list or updating the mime database as per here and here to use Brave instead of Chrome does nothing.

Why can't I set Brave as default xdg-open browser?

On a similar Arch machine, none of this happens and everything works as expected.

I think the issue is probably in the make_default_kde: No kde runtime detected message, but I can't figure out how to fix it.

AF7
  • 790
  • 1
  • 7
  • 19

2 Answers2

1

Your brave was installed from Discover or from its official website?

I was having the same problem as you, and I solved it by removing Brave (which had been installed from Discover) from my machine, and after that i installed Brave using the instructions from its website: https://brave.com/linux/.

  • Thank you, but this is not a good path for me. I greatly prefer to install all available software from the repositories, which greatly simplifies maintenance. – AF7 Jan 23 '22 at 09:36
  • 1
    @AF7 Installing Brave from the link he provided will make you add Brave's repositories, which get updates and security patches faster. – telometto Jan 24 '22 at 06:23
  • @telometto actually I see that I already did that, I forgot. Sorry. So I am already using Brave from the Brave repos, version `1.34.81 Chromium: 97.0.4692.99 (Official Build) (64-bit)`. Still, the problem persists. – AF7 Jan 25 '22 at 07:08
  • @AF7 Does [this](https://unix.stackexchange.com/questions/452174/cannot-set-default-application-for-xdg-open) help? – telometto Jan 25 '22 at 07:54
  • @telometto see my answer https://unix.stackexchange.com/a/687810/87677 – AF7 Jan 25 '22 at 08:52
0

In the end, the solution was following the instructions found in this SO answer.

The magic trick that did it for me, after manually editing the ~/.config/mimeapps.list file, was manually updating KDE's mimetype cache using kbuildsycoca5.

This raised a warning:

kf5.kservice.sycoca: Parse error in  "/home/adriano/.config/menus/applications-merged/xdg-desktop-menu-dummy.menu" , line  1 , col  1 :  "unexpected end of file"

, but browser links now correctly open in Brave.

AF7
  • 790
  • 1
  • 7
  • 19