Re: [GD-Linux] opening a URL in the default browser

"Ryan C. Gordon" <[email protected]> Sat, 13 Sep 2003 19:02:19 -0400 (EDT)
Newsgroups gmane.games.devel.linux
Message-ID <Pine.LNX.4.33.0309131850560.8714-100000@wickedsick>
> I don't believe this is possible, you have to do some convoluted
> searching for the appropriate browser.  I _think_ I've seen some
> sample source code for this, and I know our own apps supports this.

Some Unix libraries and applications follow the "BROWSER" environment
variable, in the way that "EDITOR" is generally respected as a means to
determine the preferred text editor. From python's library reference
(since they describe it well enough) ...

"Under Unix, if the environment variable BROWSER exists, it is interpreted
to override the platform default list of browsers, as a colon-separated
list of browsers to try in order. When the value of a list part contains
the string %s, then it is interpreted as a literal browser command line to
be used with the argument URL substituted for the %s; if the part does not
contain %s, it is simply interpreted as the name of the browser to
launch."

UT2003 does this, but if BROWSER isn't set, we use a default like this:

"opera:mozilla:galeon:konqueror:netscape:xterm -e links:xterm -e lynx:";

This is all trial and error, but I tried to organize the defaults in
order of what will likely be a preference if it exists on a system at all
(i.e. - If opera is installed, it's almost certain the user went out of
their way to have it, so try it first. "netscape" generally exists
on any modern Linux system if nothing more modern has been added,
and "lynx" is a desperate fallback. In more recent times, "galeon" should
probably be tried before "mozilla" for the same reason "opera" is at the
front of the list.)

It's not perfect, but it generally seems to work, and if the user gets a
browser they don't prefer by default, they can always set the environment
variable to their liking.

But there isn't an honest-to-god facility for determining the correct
browser.

--ryan.





-------------------------------------------------------
This sf.net email is sponsored by:ThinkGeek
Welcome to geek heaven.
http://thinkgeek.com/sf
_______________________________________________
Gamedevlists-linux mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/gamedevlists-linux
Archives:
http://sourceforge.net/mailarchive/forum.php?forum_id=554