aboutsummaryrefslogtreecommitdiffstats
path: root/bin/www-browser
blob: 2e8e1ae08ae7b048dd8d293ef8903213f702bbd2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
#!/bin/sh
#---------------------------------------------------------------
# Project         : Mandrakelinux
# Module          : bin
# File            : www-browser
# Version         : $Id$
# Author          : Frederic Lepied
# Created On      : Tue Aug 31 16:26:54 2004
# Purpose         : launch a web browser
#---------------------------------------------------------------

strip_browser_var() {
if [[ -n "$BROWSER" ]]; then
  if [[ `basename "$BROWSER"` == "www-browser" ]]; then
    unset BROWSER
  fi
fi
}

strip_browser_var
if [[ -z "$BROWSER" ]]; then
 
    # using GNOME
    if [[ -n "$GNOME_DESKTOP_SESSION_ID" ]]; then
	BROWSER=`gconftool -g /desktop/gnome/url-handlers/http/command | sed -e 's/%s//'`
	if [[ `gconftool -g /desktop/gnome/url-handlers/http/needs_terminal` == "true" ]]; then
  		BROWSER="xvt -e $BROWSER"
	fi
    fi

    #using KDE
    if [[ -n "$KDE_FULL_SESSION" ]]; then
	NEWBROWSER=`grep -m 1 'BrowserApplication=' $HOME/.kde/share/config/kdeglobals 2>/dev/null`
	[[ -z "$NEWBROWSER" ]] && NEWBROWSER=`grep -m 1 'BrowserApplication=' /etc/kde/kdeglobals 2>/dev/null`
	if [[ -n "$NEWBROWSER" ]]; then
  	  BROWSER=`echo $NEWBROWSER | sed -e 's/BrowserApplication=//' -e 's/!//'`
	fi
        [[ -z "$BROWSER" ]] && which kfmclient 2> /dev/null && BROWSER="kfmclient openProfile webbrowsing"
    fi

   strip_browser_var 
   
    [[ -z "$BROWSER" ]] && BROWSER=`which mozilla-firefox 2> /dev/null` 
    [[ -z "$BROWSER" ]] && BROWSER=`which epiphany 2> /dev/null`
    [[ -z "$BROWSER" ]] && BROWSER=`which galeon 2> /dev/null`
    [[ -z "$BROWSER" ]] && BROWSER=`which mozilla 2> /dev/null`
    [[ -z "$BROWSER" ]] && which kfmclient 2> /dev/null && BROWSER="kfmclient openProfile webbrowsing"
fi

if [[ -n "$BROWSER" ]]; then 
  exec $BROWSER "$@"
else
  echo "no web browser detected"
fi

# www-browser ends here