Respect / read Preferred Applications settings in Gnome (Linux)

How do I know a custom “preferred web browser” if they use the Gnome desktop environment? (I want to open a web page, I do not need to know which browser the user prefers.)

Some prerequisites: I am trying to open a browser window (my home page) using my Java application.

  • if Java version 1.6+, use Desktop.browse (url);
  • otherwise, use BareBonesBrowserLaunch.openURL (url) - this means checking the environment and launching the browser using Runtime.getRuntime (). exec ()

Method 2 runs on Windows just fine; and opens a browser on Linux. However, this is the first browser that it finds (in my case, it first searches for Firefox). In the Gnome desktop environment (for example, Ubuntu Linux by default), you can install Preferred Applications for email, browsing the Internet, etc .; I believe this information is available somewhere. How to find out which user prefers a browser?

In other words: where does Gnome save the Preferred Browser setting ?

+3
source share
3 answers

The most portable way to open a file or URL in the Linux desktop is xdg-open.

http://portland.freedesktop.org/xdg-utils-1.0/xdg-open.html

+5

~/.gconf/desktop/gnome/url-handlers/http/%gconf.xml :

<?xml version="1.0"?>
<gconf>
    <entry name="command" mtime="1243616896" type="string">
    <stringvalue>opera %s</stringvalue>
    </entry>
</gconf>

<stringvalue/> - , .

( - .)

+2

Consider use gnome-open.

I use this in Gnome and kfmclientin KDE.

+2
source

Source: https://habr.com/ru/post/1709403/


All Articles