equinor / webviz-config

Make Dash applications from a user-friendly config file :book: :snake:
https://github.com/orgs/equinor/projects/24
MIT License
55 stars 39 forks source link

Webviz launches Chromium when my OS default is Firefox #288

Open pinkwah opened 4 years ago

pinkwah commented 4 years ago

When I do webviz build [...], Webviz launcher the Chromium browser, when my OS default browser is Firefox. This happens due to a hardcoded preference for Google Chrome and Chromium:

https://github.com/equinor/webviz-config/blob/61f0fb16c377f3f821983a4e1a986cf92585d364/webviz_config/utils/_localhost_open_browser.py#L59-L63

Consider removing these lines so that my OS default browser is used rather than Chromium.

(To set default browser on GNOME: go to Settings -> Search "Default Applications" -> Select "Chromium" as your Web Browser)

anders-kiaer commented 4 years ago

Thanks @dotfloat for the report. :tada: :slightly_smiling_face:

History: The preference for Chrome/Chromium has historically been to make webviz easier to use for internal non-technical first-time users with the combination RHEL6 + KDE (where most people would have an ancient version of Konqueror as default without knowing).

Users with Chrome/Chromium installed, but having a preference to e.g. Firefox can set preferred browser.

Going forward: All users have recently moved away from RHEL6 :tada: And people are encouraged to use GNOME. Webviz has also "settled" a bit in the FMU community (= easier for users to ask questions if something goes wrong). So could consider now removing preferred browsers and go with default OS browser.

The tricky part is there are still users on RHEL7 + KDE, which I think by default gets Konquerer version 4 (from 2008!). So the best solution would perhaps be to preferably use OS default browser, but give a notice/warning if OS default is unsupported/old. However, I haven't found an easy portable way of getting browser version :thinking: Browser name looks easy though:

>>> import webbrowser
>>> 
>>> webbrowser.get().name
'firefox'
>>> 

So might be that the best possible solution is to use OS default, and communicate with/help users that don't know they have a very old default browser? :thinking:

Or we can do as Google simply give a warning if Konqueror is used :laughing: - if not explicitly configured as Webviz preferred browser.

pinkwah commented 4 years ago

Thanks for the write-up. I sympathise with the problem, although it's it seems to be a fix at the wrong level. We should bribe Knut Petter to have Firefox/Chromium be the default on KDE, even if KDE is technically unsupported in Equinor.

While I don't think there is a Python library that would do the job of notifying the user, it shouldn't be difficult to roll our own (all these browsers should respect --version), or use a Javascript library that displays a box for incompatible browser versions. The latter is well suited for when long-lived and shared webviz instances, where some other user might visit the server with their state-of-the-art Netscape Navigator 1.0

Iirc, most browser will complain about not being the default, so it's enough to nudge them in the correct direction.

pinkwah commented 3 years ago

The major issue currently is that Python's built-in webbrowser module is lackluster and will spit out xdg-open as the "browser" since it's a terminal program that exists. It's not possible to query it for more information.

XDG specified another utility called xdg-settings, which lets us write xdg-settings get default-web-browser. On my machine this spits out org.mozilla.firefox.desktop because I use the flatpak version of Firefox, but will eg. write firefox.desktop or konqueror.desktop in other cases.

I think it's possible to register a new browser in webbrowser that attempts to get the proper default web browser on Linux and then we can do version testing.