summaryrefslogtreecommitdiff
path: root/indra/newview/linux_tools/launch_url.sh
blob: d2c8919d46e0707b66d7b93ad237391507e22450 (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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
#!/bin/bash

# This script loads a web page in the 'default' graphical web browser.
# It MUST return immediately (or soon), so the browser should be
# launched in the background (thus no text-only browsers).
# This script does not trust the URL to be well-escaped or shell-safe.
#
# On Unixoids we try, in order of decreasing priority:
# - $BROWSER if set (preferred)
# - kfmclient openURL
# - x-www-browser
# - opera
# - firefox
# - mozilla
# - netscape

URL="$1"

if [ -z "$URL" ]; then
    echo "Usage: $0 URL"
    exit
fi

# restore LD_LIBRARY_PATH from SAVED_LD_LIBRARY_PATH if it exists
if [ "${SAVED_LD_LIBRARY_PATH+isset}" = "isset" ]; then
    export LD_LIBRARY_PATH="${SAVED_LD_LIBRARY_PATH}"
    echo "$0: Restored library path to '${SAVED_LD_LIBRARY_PATH}'"
fi

# if $BROWSER is defined, use it.
XBROWSER=`echo "$BROWSER" |cut -f1 -d:`
if [ ! -z "$XBROWSER" ]; then
    XBROWSER_CMD=`echo "$XBROWSER" |cut -f1 -d' '`
    # look for $XBROWSER_CMD either literally or in PATH
    if [ -x "$XBROWSER_CMD" ] || which $XBROWSER_CMD >/dev/null; then
        # check for %s string, avoiding bash2-ism of [[ ]]
	if echo "$XBROWSER" | grep %s >/dev/null; then
	    # $XBROWSER has %s which needs substituting
	    echo "$URL" | xargs -r -i%s $XBROWSER &
	    exit
	fi
        # $XBROWSER has no %s, tack URL on the end instead
	$XBROWSER "$URL" &
	exit
    fi
    echo "$0: Couldn't find the browser specified by \$BROWSER ($BROWSER)"
    echo "$0: Trying some others..."
fi

# else kfmclient
# (embodies KDE concept of 'preferred browser')
if which kfmclient >/dev/null; then
    kfmclient openURL "$URL" &
    exit
fi

# else x-www-browser
# (Debianesque idea of a working X browser)
if which x-www-browser >/dev/null; then
    x-www-browser "$URL" &
    exit
fi

# else opera
# (if user has opera in their path, they probably went to the
# trouble of installing it -> prefer it)
if which opera >/dev/null; then
    opera "$URL" &
    exit
fi

# else firefox
if which firefox >/dev/null; then
    firefox "$URL" &
    exit
fi

# else mozilla
if which mozilla >/dev/null; then
    mozilla "$URL" &
    exit
fi

# else netscape
if which netscape >/dev/null; then
    netscape "$URL" &
    exit
fi

echo '$0: Failed to find a known browser.  Please consider setting the $BROWSER environment variable.'

# end.