[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

web browser url viewing proposal



This proposal grows out of dissatisfaction with the hard-coded browser
lists provided by various programs like xchat and urlview to run a
browser displaying an url. Also a desire to do right the BROWSER
environment variable ESR proposed at
http://www.tuxedo.org/~esr/BROWSER/. Mostly because I never want to
configure again in a program what web browser to use.

It's modelled on the EDITOR and /usr/bin/editor and
/usr/bin/sensible-editor stuff already in policy, with some quirks
because the BROWSER variable is more complicated, and to allow for X and
non-X browsers.

First, the current state of the art on browser support in Debian:

- Various browsers register mime types for text/html and so on,
  and that works ok. It is out of the scope of this proposal.
- environ(7) documents the BROWSER environment variable already
- browsers provide www-browser, and things depend on it
- at least one browser (galeon) sets up a /usr/bin/x-www-browser
  alternative already
- many programs like xchat and urlview hardcode lists of browsers to use
  to open urls, and make the user pick from a list (xchat) or iterate
  through a list (urlview). These lists are frequently out of date
  (urlview will try netscape, but not mozilla, galeon, or konqeror!)

My proposal adds:

- /usr/bin/x-www-browser alternative formalized in policy
- /usr/bin/www-browser alternative added for non-X browsers
- /usr/bin/sensible-browser, presumably to debianutils, a sample
  implementation attached to this message understands BROWSER,
  and can use www-browser or x-www-browser as fallback
- programs that want to open an url in a browser can call
  sensible-browser or check BROWSER themselves with fallback

Maybe the policy editors won't want this proposal until it documents
existing policy, so until then I hope this proposal can serve as a
roadmap.

- Make at least mozilla, konqueror, w3m, lynx set up the appropriate
  alternatives.
- Add sensible-browser to debianutils.
- Modify some programs to use BROWSER and the alternatives, or
  sensible-browser:
     - urlview (partial patch at http://www.tuxedo.org/~esr/BROWSER/)
     - xchat (just add sensible-browser to the top of its list, maybe?)
     - possibly emacs (partial patch same place)
     - maybe python (already supports BROWSER in webbrowser.py, would
       need alternatives fallback added)
- Get proposal into policy.

Here is the text of the proposal to be added after section 12.4. of
policy:

Web browsers
------------

Some programs have the ability to launch a web browser to display an URL.
Since there are lots of different web browsers available in the Debian
distribution, the system administrator and each user should have the
possibility to choose a preferred web browser.

In addition, programs should choose a good default web browser if none
is selected by the user or system administrator.

Thus, every program that launches a web browser with an URL must use the
BROWSER environment variable to determine what browser the user wishes
to use.

The value of BROWSER may consist of a colon-separated series of browser
command parts. These should be tried in order until one succeeds. Each command
part may optionally contain the string "%s"; if it does, the URL to be viewed
is substituted there. If a command part does not contain %s, the browser is to
be launched as if the URL had been supplied as its first argument. The string
%% must be substituted as a single %.
<footnote>
This browser variable was proposed by Eric Raymond at
http://www.tuxedo.org/~esr/BROWSER/
</footnote>

If the BROWSER environment variable is not set, the program should use
/usr/bin/x-www-browser if there is an available X Window System DISPLAY,
and /usr/bin/www-browser if not. These two files are managed through the dpkg
alternatives mechanism. Thus every package providing a general-purpose 
web browser must call the update-alternatives program to register
the appopriate one of these alternatives.

If it is very hard to adapt a program to make use of the BROWSER variable,
that program may be configured to use /usr/bin/sensible-www-browser
instead. This is a program provided by the Debian base system that checks
the BROWSER environment variable, and falls back to /usr/bin/x-www-browser
or /usr/bin/www-browser if it is not set.

-- 
see shy jo
#!/usr/bin/perl
# This program is copyright 2002 by Joey Hess <joeyh@debian.org>,
# and is licensed under the terms of the GNU GPL, version 2 or higher.
my $url=shift;
if (exists $ENV{BROWSER}) {
	foreach (split ':' , $ENV{BROWSER}) {
		if (/%s/) {
			# substitute %s with url, and %% to %.
			s/%([%s])/$1 eq '%' ? '%' : $url/eg;
		}
		else {
			$_.=' '.$url;
		}
		exec $_;
		# on failure, continue to next in list
	}

	print STDERR "None of the browsers in \$BROWSER worked!\n";
	exit 1;
}

if (exists $ENV{DISPLAY} && -e '/usr/bin/x-www-browser') {
	exec '/usr/bin/x-www-browser', $url;
	exit 1;
}

if (-e '/usr/bin/www-browser') {
	exec '/usr/bin/www-browser', $url;
	exit 1;
}

print STDERR "Couldn't find a web browser!\n";
print STDERR "Set the BROWSER environment variable to your desired browser.\n";
exit 1;
.\" -*- nroff -*-
.TH SENSIBLE-BROWSER 1 "18 Nov 2002" "Debian"
.SH NAME
sensible-browser \- sensible web browsing
.SH SYNOPSIS
.BR sensible-browser
url
.SH DESCRIPTION
.BR sensible-browser
makes a sensible decision of which web browser to call to view an URL.
Programs in Debian can use this program as their default web browser,
or emulate its behavior.
.SH "SEE ALSO"
.B environ (7)

Attachment: pgpq7EVyoQ5QO.pgp
Description: PGP signature


Reply to: