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