PageRenderTime 389ms CodeModel.GetById 181ms app.highlight 15ms RepoModel.GetById 187ms app.codeStats 0ms

/indra/newview/linux_tools/launch_url.sh

https://bitbucket.org/lindenlab/viewer-beta/
Shell | 86 lines | 63 code | 5 blank | 18 comment | 6 complexity | e1870e2727094071cafc3f1c36676209 MD5 | raw file
 1#!/bin/bash
 2
 3# This script loads a web page in the 'default' graphical web browser.
 4# It MUST return immediately (or soon), so the browser should be
 5# launched in the background (thus no text-only browsers).
 6# This script does not trust the URL to be well-escaped or shell-safe.
 7#
 8# On Unixoids we try, in order of decreasing priority:
 9# - $BROWSER if set (preferred)
10# - Default GNOME browser
11# - Default KDE browser
12# - x-www-browser
13# - The first browser in $BROWSER_COMMANDS that is found.
14
15URL="$1"
16
17if [ -z "$URL" ]; then
18    echo "Usage: $(basename "$0") URL"
19    exit
20fi
21
22# restore LD_LIBRARY_PATH from SAVED_LD_LIBRARY_PATH if it exists
23if [ "${SAVED_LD_LIBRARY_PATH+isset}" = "isset" ]; then
24    export LD_LIBRARY_PATH="${SAVED_LD_LIBRARY_PATH}"
25    echo "$0: Restored library path to '${SAVED_LD_LIBRARY_PATH}'"
26fi
27
28# if $BROWSER is defined, use it.
29XBROWSER=`echo "$BROWSER" |cut -f1 -d:`
30if [ ! -z "$XBROWSER" ]; then
31    XBROWSER_CMD=`echo "$XBROWSER" |cut -f1 -d' '`
32    # look for $XBROWSER_CMD either literally or in PATH
33    if [ -x "$XBROWSER_CMD" ] || which $XBROWSER_CMD >/dev/null; then
34        # check for %s string, avoiding bash2-ism of [[ ]]
35	if echo "$XBROWSER" | grep %s >/dev/null; then
36	    # $XBROWSER has %s which needs substituting
37	    echo "$URL" | xargs -r -i%s $XBROWSER &
38	    exit
39	fi
40        # $XBROWSER has no %s, tack URL on the end instead
41	$XBROWSER "$URL" &
42	exit
43    fi
44    echo "$0: Couldn't find the browser specified by \$BROWSER ($BROWSER)"
45    echo "$0: Trying some others..."
46fi
47
48# Launcher the default GNOME browser.
49if [ ! -z "$GNOME_DESKTOP_SESSION_ID" ] && which gnome-open >/dev/null; then
50    gnome-open "$URL" &
51    exit
52fi
53
54# Launch the default KDE browser.
55if [ ! -z "$KDE_FULL_SESSION" ] && which kfmclient >/dev/null; then
56    kfmclient openURL "$URL" &
57    exit
58fi
59
60# List of browser commands that will be tried in the order listed. x-www-browser
61# will be tried first, which is a debian alternative.
62BROWSER_COMMANDS="      \
63    x-www-browser       \
64    firefox             \
65    mozilla-firefox     \
66    iceweasel           \
67    iceape              \
68    opera               \
69    epiphany-browser    \
70    epiphany-gecko      \
71    epiphany-webkit     \
72    epiphany            \
73    mozilla             \
74    seamonkey           \
75    galeon              \
76    dillo               \
77    netscape"
78for browser_cmd in $BROWSER_COMMANDS; do
79    if which $browser_cmd >/dev/null; then
80	$browser_cmd "$URL" &
81        exit
82   fi
83done
84
85echo '$0: Failed to find a known browser.  Please consider setting the $BROWSER environment variable.'
86exit 1