Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Opening links does not use XDG/Debian default browser (Linux) #9825

Closed
0cjs opened this issue Nov 28, 2020 · 8 comments
Closed

Opening links does not use XDG/Debian default browser (Linux) #9825

0cjs opened this issue Nov 28, 2020 · 8 comments

Comments

@0cjs
Copy link

0cjs commented Nov 28, 2020

I'm using Debian 9 (fully up to date), a custom fvwm (window manager) configuration with a few XFCE programs, and the Telegram desktop client from the official website, version 2.4.7.

Until some recent update, clicking on a link in Telegram opened a new tab in my XDG/Debian default web browser, google-chrome-stable. This behaviour has since changed (I'm not sure when, but no more than three months ago at the outside) and Telegram now starts chromium. All of sensible-browser, xdg-open and x-www-browser are still opening links using google-chrome-stable.

$ xdg-settings get default-web-browser
google-chrome.desktop
$ xdg-settings get default-url-scheme-handler http
xdg-settings: default-url-scheme-handler not implemented for xfce
3 $ xdg-settings get default-url-scheme-handler https
xdg-settings: default-url-scheme-handler not implemented for xfce
3 $ update-alternatives --display x-www-browser
x-www-browser - auto mode
  link best version is /usr/bin/google-chrome-stable
  link currently points to /usr/bin/google-chrome-stable
  link x-www-browser is /usr/bin/x-www-browser
  slave x-www-browser.1.gz is /usr/share/man/man1/x-www-browser.1.gz
/usr/bin/chromium - priority 40
/usr/bin/firefox-esr - priority 70
  slave x-www-browser.1.gz: /usr/share/man/man1/firefox-esr.1.gz
/usr/bin/google-chrome-stable - priority 200

Removing the chromium package is a workaround; Telegram then starts opening links in google-chrome-stable.

It appears that some of the commenters (but not the original poster) in issue #8982 may be experiencing this issue as well.

@ilya-fedin
Copy link
Contributor

If Telegram doesn't open the right browser for you, that means that your defaults are misconfured and Telegram won't be the only application that opens wrong browser, since a lot of applications (mostly GTK ones) use the same way that uses Telegram.

@0cjs
Copy link
Author

0cjs commented Nov 29, 2020

@ilya-fedin @Aokromes

...that means that your defaults are misconfured and Telegram won't be the only application that opens wrong browser, since a lot of applications (mostly GTK ones) use the same way that uses Telegram.

Vague statements such as "your defaults are misconfigured," especially when I display several correctly configured defaults in my problem description and show three different programs that do open the correct browser, aren't too helpful.

Fortunately, you did perhaps inadvertantly drop a clue as to what you guys are doing to open a browser when you mentioned GTK applications. Like everything else so far except Telegram, gnome-www-browser opens google-chrome, but I installed gnome-open on my system and as it turns out, I can replicate the problem with that; it opens chromium, despite the system setting for the Gnome browser being google-chrome:

$ update-alternatives --display gnome-www-browser
gnome-www-browser - auto mode
  link best version is /usr/bin/google-chrome-stable
  link currently points to /usr/bin/google-chrome-stable
  link gnome-www-browser is /usr/bin/gnome-www-browser
  slave gnome-www-browser.1.gz is /usr/share/man/man1/gnome-www-browser.1.gz
/usr/bin/chromium - priority 40
/usr/bin/firefox-esr - priority 70
  slave gnome-www-browser.1.gz: /usr/share/man/man1/firefox-esr.1.gz
/usr/bin/google-chrome-stable - priority 200

So it seems to be some sort of user setting. I don't use the Gnome desktop, but looking through the output of gconf-tool -R /, and gconf-tool-2 -R /, my defaults seem to be set correctly:

    /desktop/gnome/url-handlers/http:
     command = sensible-browser %s
     needs_terminal = false
     enabled = true
...
    /desktop/gnome/url-handlers/https:
     command = sensible-browser %s
     needs_terminal = false
     enabled = true

So where are you and gnome-open (which may be a Gnome 2 application?) getting your defaults from?

@0cjs
Copy link
Author

0cjs commented Nov 29, 2020

So, some mucking about seems to indicate that you and gnome-open are using the XDG x-scheme-handler/http and x-scheme-handler/https MIME types to determine the browser to use. Note that xdg-open is not using this, as I pointed out in my original message. So here's why I'm seeing the problem:

$ xdg-mime query default text/html
google-chrome.desktop
$ xdg-mime query default x-scheme-handler/http
chromium.desktop
$ xdg-mime query default x-scheme-handler/https
chromium.desktop

Running the following fixed the problem for both gnome-open and Telegram:

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

I'm not clear on what's going on with this, and particularly what's up with the difference between xdg-open behaviour and your behaviour, but I'm not feeling particularly inclined to pursue it at the moment.

@ilya-fedin
Copy link
Contributor

So where are you and gnome-open (which may be a Gnome 2 application?) getting your defaults from?

tdesktop uses g_app_info_launch_default_for_uri, like most applications on Linux

@0cjs
Copy link
Author

0cjs commented Nov 29, 2020

tdesktop uses g_app_info_launch_default_for_uri, like most applications on Linux

Ah, that helps a lot. It's now clear what changed and when: before commit 41e0e4f tdesktop was running xdg-open and after that it is calling g_app_info_launch_default_for_uri().

It's still a mystery to me what's up with the difference between xdg-open' and glib's behaviour. You'd think that xdg-open would be doing the right thing with regard to XDG MIME types, especially given that the association spec hasn't changed in six years, but glib's behaviour does seem to make more sense at first glance.

@ilya-fedin
Copy link
Contributor

xdg-open is a poorly maintained shell script that incolmpatible with the XDG spec in some places and has stupid mimeopen shell/perl code for WM only environment

@0cjs
Copy link
Author

0cjs commented Nov 29, 2020

Oh, well that explains it, then. I now know not to rely on that for testing my XDG configuration. Thanks!

@github-actions
Copy link

github-actions bot commented Mar 4, 2021

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Mar 4, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants