"Fossies" - the Fresh Open Source Software Archive

Member "Atom/resources/app/apm/node_modules/open/vendor/xdg-open" (8 Mar 2017, 19086 Bytes) of archive /windows/misc/atom-windows.zip:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) Bash source code syntax highlighting (style: standard) with prefixed line numbers. Alternatively you can here view or download the uninterpreted source code file.

    1 #!/bin/sh
    2 #---------------------------------------------
    3 #   xdg-open
    4 #
    5 #   Utility script to open a URL in the registered default application.
    6 #
    7 #   Refer to the usage() function below for usage.
    8 #
    9 #   Copyright 2009-2010, Fathi Boudra <fabo@freedesktop.org>
   10 #   Copyright 2009-2010, Rex Dieter <rdieter@fedoraproject.org>
   11 #   Copyright 2006, Kevin Krammer <kevin.krammer@gmx.at>
   12 #   Copyright 2006, Jeremy White <jwhite@codeweavers.com>
   13 #
   14 #   LICENSE:
   15 #
   16 #   Permission is hereby granted, free of charge, to any person obtaining a
   17 #   copy of this software and associated documentation files (the "Software"),
   18 #   to deal in the Software without restriction, including without limitation
   19 #   the rights to use, copy, modify, merge, publish, distribute, sublicense,
   20 #   and/or sell copies of the Software, and to permit persons to whom the
   21 #   Software is furnished to do so, subject to the following conditions:
   22 #
   23 #   The above copyright notice and this permission notice shall be included
   24 #   in all copies or substantial portions of the Software.
   25 #
   26 #   THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
   27 #   OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
   28 #   FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
   29 #   THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
   30 #   OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
   31 #   ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
   32 #   OTHER DEALINGS IN THE SOFTWARE.
   33 #
   34 #---------------------------------------------
   35 
   36 manualpage()
   37 {
   38 cat << _MANUALPAGE
   39 Name
   40 
   41    xdg-open -- opens a file or URL in the user's preferred
   42    application
   43 
   44 Synopsis
   45 
   46    xdg-open { file | URL }
   47 
   48    xdg-open { --help | --manual | --version }
   49 
   50 Description
   51 
   52    xdg-open opens a file or URL in the user's preferred
   53    application. If a URL is provided the URL will be opened in the
   54    user's preferred web browser. If a file is provided the file
   55    will be opened in the preferred application for files of that
   56    type. xdg-open supports file, ftp, http and https URLs.
   57 
   58    xdg-open is for use inside a desktop session only. It is not
   59    recommended to use xdg-open as root.
   60 
   61 Options
   62 
   63    --help
   64           Show command synopsis.
   65 
   66    --manual
   67           Show this manual page.
   68 
   69    --version
   70           Show the xdg-utils version information.
   71 
   72 Exit Codes
   73 
   74    An exit code of 0 indicates success while a non-zero exit code
   75    indicates failure. The following failure codes can be returned:
   76 
   77    1
   78           Error in command line syntax.
   79 
   80    2
   81           One of the files passed on the command line did not
   82           exist.
   83 
   84    3
   85           A required tool could not be found.
   86 
   87    4
   88           The action failed.
   89 
   90 Examples
   91 
   92 xdg-open 'http://www.freedesktop.org/'
   93 
   94    Opens the freedesktop.org website in the user's default
   95    browser.
   96 
   97 xdg-open /tmp/foobar.png
   98 
   99    Opens the PNG image file /tmp/foobar.png in the user's default
  100    image viewing application.
  101 _MANUALPAGE
  102 }
  103 
  104 usage()
  105 {
  106 cat << _USAGE
  107    xdg-open -- opens a file or URL in the user's preferred
  108    application
  109 
  110 Synopsis
  111 
  112    xdg-open { file | URL }
  113 
  114    xdg-open { --help | --manual | --version }
  115 
  116 _USAGE
  117 }
  118 
  119 #@xdg-utils-common@
  120 
  121 #----------------------------------------------------------------------------
  122 #   Common utility functions included in all XDG wrapper scripts
  123 #----------------------------------------------------------------------------
  124 
  125 DEBUG()
  126 {
  127   [ -z "${XDG_UTILS_DEBUG_LEVEL}" ] && return 0;
  128   [ ${XDG_UTILS_DEBUG_LEVEL} -lt $1 ] && return 0;
  129   shift
  130   echo "$@" >&2
  131 }
  132 
  133 # This handles backslashes but not quote marks.
  134 first_word()
  135 {
  136     read first rest
  137     echo "$first"
  138 }
  139 
  140 #-------------------------------------------------------------
  141 # map a binary to a .desktop file
  142 binary_to_desktop_file()
  143 {
  144     search="${XDG_DATA_HOME:-$HOME/.local/share}:${XDG_DATA_DIRS:-/usr/local/share:/usr/share}"
  145     binary="`which "$1"`"
  146     binary="`readlink -f "$binary"`"
  147     base="`basename "$binary"`"
  148     IFS=:
  149     for dir in $search; do
  150         unset IFS
  151         [ "$dir" ] || continue
  152         [ -d "$dir/applications" ] || [ -d "$dir/applnk" ] || continue
  153         for file in "$dir"/applications/*.desktop "$dir"/applications/*/*.desktop "$dir"/applnk/*.desktop "$dir"/applnk/*/*.desktop; do
  154             [ -r "$file" ] || continue
  155             # Check to make sure it's worth the processing.
  156             grep -q "^Exec.*$base" "$file" || continue
  157             # Make sure it's a visible desktop file (e.g. not "preferred-web-browser.desktop").
  158             grep -Eq "^(NoDisplay|Hidden)=true" "$file" && continue
  159             command="`grep -E "^Exec(\[[^]=]*])?=" "$file" | cut -d= -f 2- | first_word`"
  160             command="`which "$command"`"
  161             if [ x"`readlink -f "$command"`" = x"$binary" ]; then
  162                 # Fix any double slashes that got added path composition
  163                 echo "$file" | sed -e 's,//*,/,g'
  164                 return
  165             fi
  166         done
  167     done
  168 }
  169 
  170 #-------------------------------------------------------------
  171 # map a .desktop file to a binary
  172 ## FIXME: handle vendor dir case
  173 desktop_file_to_binary()
  174 {
  175     search="${XDG_DATA_HOME:-$HOME/.local/share}:${XDG_DATA_DIRS:-/usr/local/share:/usr/share}"
  176     desktop="`basename "$1"`"
  177     IFS=:
  178     for dir in $search; do
  179         unset IFS
  180         [ "$dir" ] && [ -d "$dir/applications" ] || continue
  181         file="$dir/applications/$desktop"
  182         [ -r "$file" ] || continue
  183         # Remove any arguments (%F, %f, %U, %u, etc.).
  184         command="`grep -E "^Exec(\[[^]=]*])?=" "$file" | cut -d= -f 2- | first_word`"
  185         command="`which "$command"`"
  186         readlink -f "$command"
  187         return
  188     done
  189 }
  190 
  191 #-------------------------------------------------------------
  192 # Exit script on successfully completing the desired operation
  193 
  194 exit_success()
  195 {
  196     if [ $# -gt 0 ]; then
  197         echo "$@"
  198         echo
  199     fi
  200 
  201     exit 0
  202 }
  203 
  204 
  205 #-----------------------------------------
  206 # Exit script on malformed arguments, not enough arguments
  207 # or missing required option.
  208 # prints usage information
  209 
  210 exit_failure_syntax()
  211 {
  212     if [ $# -gt 0 ]; then
  213         echo "xdg-open: $@" >&2
  214         echo "Try 'xdg-open --help' for more information." >&2
  215     else
  216         usage
  217         echo "Use 'man xdg-open' or 'xdg-open --manual' for additional info."
  218     fi
  219 
  220     exit 1
  221 }
  222 
  223 #-------------------------------------------------------------
  224 # Exit script on missing file specified on command line
  225 
  226 exit_failure_file_missing()
  227 {
  228     if [ $# -gt 0 ]; then
  229         echo "xdg-open: $@" >&2
  230     fi
  231 
  232     exit 2
  233 }
  234 
  235 #-------------------------------------------------------------
  236 # Exit script on failure to locate necessary tool applications
  237 
  238 exit_failure_operation_impossible()
  239 {
  240     if [ $# -gt 0 ]; then
  241         echo "xdg-open: $@" >&2
  242     fi
  243 
  244     exit 3
  245 }
  246 
  247 #-------------------------------------------------------------
  248 # Exit script on failure returned by a tool application
  249 
  250 exit_failure_operation_failed()
  251 {
  252     if [ $# -gt 0 ]; then
  253         echo "xdg-open: $@" >&2
  254     fi
  255 
  256     exit 4
  257 }
  258 
  259 #------------------------------------------------------------
  260 # Exit script on insufficient permission to read a specified file
  261 
  262 exit_failure_file_permission_read()
  263 {
  264     if [ $# -gt 0 ]; then
  265         echo "xdg-open: $@" >&2
  266     fi
  267 
  268     exit 5
  269 }
  270 
  271 #------------------------------------------------------------
  272 # Exit script on insufficient permission to write a specified file
  273 
  274 exit_failure_file_permission_write()
  275 {
  276     if [ $# -gt 0 ]; then
  277         echo "xdg-open: $@" >&2
  278     fi
  279 
  280     exit 6
  281 }
  282 
  283 check_input_file()
  284 {
  285     if [ ! -e "$1" ]; then
  286         exit_failure_file_missing "file '$1' does not exist"
  287     fi
  288     if [ ! -r "$1" ]; then
  289         exit_failure_file_permission_read "no permission to read file '$1'"
  290     fi
  291 }
  292 
  293 check_vendor_prefix()
  294 {
  295     file_label="$2"
  296     [ -n "$file_label" ] || file_label="filename"
  297     file=`basename "$1"`
  298     case "$file" in
  299        [a-zA-Z]*-*)
  300          return
  301          ;;
  302     esac
  303 
  304     echo "xdg-open: $file_label '$file' does not have a proper vendor prefix" >&2
  305     echo 'A vendor prefix consists of alpha characters ([a-zA-Z]) and is terminated' >&2
  306     echo 'with a dash ("-"). An example '"$file_label"' is '"'example-$file'" >&2
  307     echo "Use --novendor to override or 'xdg-open --manual' for additional info." >&2
  308     exit 1
  309 }
  310 
  311 check_output_file()
  312 {
  313     # if the file exists, check if it is writeable
  314     # if it does not exists, check if we are allowed to write on the directory
  315     if [ -e "$1" ]; then
  316         if [ ! -w "$1" ]; then
  317             exit_failure_file_permission_write "no permission to write to file '$1'"
  318         fi
  319     else
  320         DIR=`dirname "$1"`
  321         if [ ! -w "$DIR" ] || [ ! -x "$DIR" ]; then
  322             exit_failure_file_permission_write "no permission to create file '$1'"
  323         fi
  324     fi
  325 }
  326 
  327 #----------------------------------------
  328 # Checks for shared commands, e.g. --help
  329 
  330 check_common_commands()
  331 {
  332     while [ $# -gt 0 ] ; do
  333         parm="$1"
  334         shift
  335 
  336         case "$parm" in
  337             --help)
  338             usage
  339             echo "Use 'man xdg-open' or 'xdg-open --manual' for additional info."
  340             exit_success
  341             ;;
  342 
  343             --manual)
  344             manualpage
  345             exit_success
  346             ;;
  347 
  348             --version)
  349             echo "xdg-open 1.1.0 rc1"
  350             exit_success
  351             ;;
  352         esac
  353     done
  354 }
  355 
  356 check_common_commands "$@"
  357 
  358 [ -z "${XDG_UTILS_DEBUG_LEVEL}" ] && unset XDG_UTILS_DEBUG_LEVEL;
  359 if [ ${XDG_UTILS_DEBUG_LEVEL-0} -lt 1 ]; then
  360     # Be silent
  361     xdg_redirect_output=" > /dev/null 2> /dev/null"
  362 else
  363     # All output to stderr
  364     xdg_redirect_output=" >&2"
  365 fi
  366 
  367 #--------------------------------------
  368 # Checks for known desktop environments
  369 # set variable DE to the desktop environments name, lowercase
  370 
  371 detectDE()
  372 {
  373     # see https://bugs.freedesktop.org/show_bug.cgi?id=34164
  374     unset GREP_OPTIONS
  375 
  376     if [ -n "${XDG_CURRENT_DESKTOP}" ]; then
  377       case "${XDG_CURRENT_DESKTOP}" in
  378          GNOME)
  379            DE=gnome;
  380            ;;
  381          KDE)
  382            DE=kde;
  383            ;;
  384          LXDE)
  385            DE=lxde;
  386            ;;
  387          XFCE)
  388            DE=xfce
  389       esac
  390     fi
  391 
  392     if [ x"$DE" = x"" ]; then
  393       # classic fallbacks
  394       if [ x"$KDE_FULL_SESSION" = x"true" ]; then DE=kde;
  395       elif [ x"$GNOME_DESKTOP_SESSION_ID" != x"" ]; then DE=gnome;
  396       elif [ x"$MATE_DESKTOP_SESSION_ID" != x"" ]; then DE=mate;
  397       elif `dbus-send --print-reply --dest=org.freedesktop.DBus /org/freedesktop/DBus org.freedesktop.DBus.GetNameOwner string:org.gnome.SessionManager > /dev/null 2>&1` ; then DE=gnome;
  398       elif xprop -root _DT_SAVE_MODE 2> /dev/null | grep ' = \"xfce4\"$' >/dev/null 2>&1; then DE=xfce;
  399       elif xprop -root 2> /dev/null | grep -i '^xfce_desktop_window' >/dev/null 2>&1; then DE=xfce
  400       fi
  401     fi
  402 
  403     if [ x"$DE" = x"" ]; then
  404       # fallback to checking $DESKTOP_SESSION
  405       case "$DESKTOP_SESSION" in
  406          gnome)
  407            DE=gnome;
  408            ;;
  409          LXDE|Lubuntu)
  410            DE=lxde; 
  411            ;;
  412          xfce|xfce4|'Xfce Session')
  413            DE=xfce;
  414            ;;
  415       esac
  416     fi
  417 
  418     if [ x"$DE" = x"" ]; then
  419       # fallback to uname output for other platforms
  420       case "$(uname 2>/dev/null)" in 
  421         Darwin)
  422           DE=darwin;
  423           ;;
  424       esac
  425     fi
  426 
  427     if [ x"$DE" = x"gnome" ]; then
  428       # gnome-default-applications-properties is only available in GNOME 2.x
  429       # but not in GNOME 3.x
  430       which gnome-default-applications-properties > /dev/null 2>&1  || DE="gnome3"
  431     fi
  432 }
  433 
  434 #----------------------------------------------------------------------------
  435 # kfmclient exec/openURL can give bogus exit value in KDE <= 3.5.4
  436 # It also always returns 1 in KDE 3.4 and earlier
  437 # Simply return 0 in such case
  438 
  439 kfmclient_fix_exit_code()
  440 {
  441     version=`LC_ALL=C.UTF-8 kde-config --version 2>/dev/null | grep '^KDE'`
  442     major=`echo $version | sed 's/KDE.*: \([0-9]\).*/\1/'`
  443     minor=`echo $version | sed 's/KDE.*: [0-9]*\.\([0-9]\).*/\1/'`
  444     release=`echo $version | sed 's/KDE.*: [0-9]*\.[0-9]*\.\([0-9]\).*/\1/'`
  445     test "$major" -gt 3 && return $1
  446     test "$minor" -gt 5 && return $1
  447     test "$release" -gt 4 && return $1
  448     return 0
  449 }
  450 
  451 # This handles backslashes but not quote marks.
  452 first_word()
  453 {
  454     read first rest
  455     echo "$first"
  456 }
  457 
  458 last_word()
  459 {
  460     read first rest
  461     echo "$rest"
  462 }
  463 
  464 open_darwin()
  465 {
  466     open "$1"
  467 
  468     if [ $? -eq 0 ]; then
  469         exit_success
  470     else
  471         exit_failure_operation_failed
  472     fi
  473 }
  474 
  475 open_kde()
  476 {
  477     if kde-open -v 2>/dev/null 1>&2; then
  478         kde-open "$1"
  479     else
  480         if [ x"$KDE_SESSION_VERSION" = x"4" ]; then
  481             kfmclient openURL "$1"
  482         else
  483             kfmclient exec "$1"
  484             kfmclient_fix_exit_code $?
  485         fi
  486     fi
  487 
  488     if [ $? -eq 0 ]; then
  489         exit_success
  490     else
  491         exit_failure_operation_failed
  492     fi
  493 }
  494 
  495 open_gnome()
  496 {
  497     if gvfs-open --help 2>/dev/null 1>&2; then
  498         gvfs-open "$1"
  499     else
  500         gnome-open "$1"
  501     fi
  502 
  503     if [ $? -eq 0 ]; then
  504         exit_success
  505     else
  506         exit_failure_operation_failed
  507     fi
  508 }
  509 
  510 open_mate()
  511 {
  512     if gvfs-open --help 2>/dev/null 1>&2; then
  513         gvfs-open "$1"
  514     else
  515         mate-open "$1"
  516     fi
  517 
  518     if [ $? -eq 0 ]; then
  519         exit_success
  520     else
  521         exit_failure_operation_failed
  522     fi
  523 }
  524 
  525 open_xfce()
  526 {
  527     exo-open "$1"
  528 
  529     if [ $? -eq 0 ]; then
  530         exit_success
  531     else
  532         exit_failure_operation_failed
  533     fi
  534 }
  535 
  536 #-----------------------------------------
  537 # Recursively search .desktop file
  538 
  539 search_desktop_file()
  540 {
  541     local default="$1"
  542     local dir="$2"
  543     local arg="$3"
  544 
  545     local file=""
  546     # look for both vendor-app.desktop, vendor/app.desktop
  547     if [ -r "$dir/$default" ]; then
  548       file="$dir/$default"
  549     elif [ -r "$dir/`echo $default | sed -e 's|-|/|'`" ]; then
  550       file="$dir/`echo $default | sed -e 's|-|/|'`"
  551     fi
  552 
  553     if [ -r "$file" ] ; then
  554         command="`grep -E "^Exec(\[[^]=]*])?=" "$file" | cut -d= -f 2- | first_word`"
  555         command_exec=`which $command 2>/dev/null`
  556         arguments="`grep -E "^Exec(\[[^]=]*])?=" "$file" | cut -d= -f 2- | last_word`"
  557         arg_one="`echo $arg | sed 's/&/\\\\&/g'`"
  558         arguments_exec="`echo $arguments | sed -e 's*%[fFuU]*"'"$arg_one"'"*g'`"
  559 
  560         if [ -x "$command_exec" ] ; then
  561             if echo $arguments | grep -iq '%[fFuU]' ; then
  562                 echo START $command_exec $arguments_exec
  563                 eval $command_exec $arguments_exec
  564             else
  565                 echo START $command_exec $arguments_exec "$arg"
  566                 eval $command_exec $arguments_exec "$arg"
  567             fi
  568 
  569             if [ $? -eq 0 ]; then
  570                 exit_success
  571             fi
  572         fi
  573     fi
  574 
  575     for d in $dir/*/; do
  576         [ -d "$d" ] && search_desktop_file "$default" "$d" "$arg"
  577     done
  578 }
  579 
  580 
  581 open_generic_xdg_mime()
  582 {
  583     filetype="$2"
  584     default=`xdg-mime query default "$filetype"`
  585     if [ -n "$default" ] ; then
  586         xdg_user_dir="$XDG_DATA_HOME"
  587         [ -n "$xdg_user_dir" ] || xdg_user_dir="$HOME/.local/share"
  588 
  589         xdg_system_dirs="$XDG_DATA_DIRS"
  590         [ -n "$xdg_system_dirs" ] || xdg_system_dirs=/usr/local/share/:/usr/share/
  591 
  592 DEBUG 3 "$xdg_user_dir:$xdg_system_dirs"
  593         for x in `echo "$xdg_user_dir:$xdg_system_dirs" | sed 's/:/ /g'`; do
  594             search_desktop_file "$default" "$x/applications/" "$1"
  595         done
  596     fi
  597 }
  598 
  599 open_generic_xdg_file_mime()
  600 {
  601     filetype=`xdg-mime query filetype "$1" | sed "s/;.*//"`
  602     open_generic_xdg_mime "$1" "$filetype"
  603 }
  604 
  605 open_generic_xdg_x_scheme_handler()
  606 {
  607     scheme="`echo $1 | sed -n 's/\(^[[:alnum:]+\.-]*\):.*$/\1/p'`"
  608     if [ -n $scheme ]; then
  609         filetype="x-scheme-handler/$scheme"
  610         open_generic_xdg_mime "$1" "$filetype"
  611     fi
  612 }
  613 
  614 open_generic()
  615 {
  616     # Paths or file:// URLs
  617     if (echo "$1" | grep -q '^file://' ||
  618         ! echo "$1" | egrep -q '^[[:alpha:]+\.\-]+:'); then
  619 
  620         local file="$1"
  621 
  622         # Decode URLs
  623         if echo "$file" | grep -q '^file:///'; then
  624             file=${file#file://}
  625             file="$(printf "$(echo "$file" | sed -e 's@%\([a-f0-9A-F]\{2\}\)@\\x\1@g')")"
  626         fi
  627         check_input_file "$file"
  628 
  629         open_generic_xdg_file_mime "$file"
  630 
  631         if [ -f /etc/debian_version ] &&
  632             which run-mailcap 2>/dev/null 1>&2; then
  633             run-mailcap --action=view "$file"
  634             if [ $? -eq 0 ]; then
  635                 exit_success
  636             fi
  637         fi
  638 
  639         if mimeopen -v 2>/dev/null 1>&2; then
  640             mimeopen -L -n "$file"
  641             if [ $? -eq 0 ]; then
  642                 exit_success
  643             fi
  644         fi
  645     fi
  646 
  647     open_generic_xdg_x_scheme_handler "$1"
  648 
  649     IFS=":"
  650     for browser in $BROWSER; do
  651         if [ x"$browser" != x"" ]; then
  652 
  653             browser_with_arg=`printf "$browser" "$1" 2>/dev/null`
  654             if [ $? -ne 0 ]; then
  655                 browser_with_arg=$browser;
  656             fi
  657 
  658             if [ x"$browser_with_arg" = x"$browser" ]; then
  659                 eval '$browser $1'$xdg_redirect_output;
  660             else eval '$browser_with_arg'$xdg_redirect_output;
  661             fi
  662 
  663             if [ $? -eq 0 ]; then
  664                 exit_success;
  665             fi
  666         fi
  667     done
  668 
  669     exit_failure_operation_impossible "no method available for opening '$1'"
  670 }
  671 
  672 open_lxde()
  673 {
  674     # pcmanfm only knows how to handle file:// urls and filepaths, it seems.
  675     if (echo "$1" | grep -q '^file://' ||
  676         ! echo "$1" | egrep -q '^[[:alpha:]+\.\-]+:')
  677     then
  678         local file="$(echo "$1" | sed 's%^file://%%')"
  679 
  680         # handle relative paths
  681         if ! echo "$file" | grep -q '^/'; then
  682             file="$(pwd)/$file"
  683         fi
  684 
  685         pcmanfm "$file"
  686 
  687     else
  688         open_generic "$1"
  689     fi
  690 
  691     if [ $? -eq 0 ]; then
  692         exit_success
  693     else
  694         exit_failure_operation_failed
  695     fi
  696 }
  697 
  698 [ x"$1" != x"" ] || exit_failure_syntax
  699 
  700 url=
  701 while [ $# -gt 0 ] ; do
  702     parm="$1"
  703     shift
  704 
  705     case "$parm" in
  706       -*)
  707         exit_failure_syntax "unexpected option '$parm'"
  708         ;;
  709 
  710       *)
  711         if [ -n "$url" ] ; then
  712             exit_failure_syntax "unexpected argument '$parm'"
  713         fi
  714         url="$parm"
  715         ;;
  716     esac
  717 done
  718 
  719 if [ -z "${url}" ] ; then
  720     exit_failure_syntax "file or URL argument missing"
  721 fi
  722 
  723 detectDE
  724 
  725 if [ x"$DE" = x"" ]; then
  726     DE=generic
  727 fi
  728 
  729 DEBUG 2 "Selected DE $DE"
  730 
  731 # if BROWSER variable is not set, check some well known browsers instead
  732 if [ x"$BROWSER" = x"" ]; then
  733     BROWSER=links2:elinks:links:lynx:w3m
  734     if [ -n "$DISPLAY" ]; then
  735         BROWSER=x-www-browser:firefox:seamonkey:mozilla:epiphany:konqueror:chromium-browser:google-chrome:$BROWSER
  736     fi
  737 fi
  738 
  739 case "$DE" in
  740     kde)
  741     open_kde "$url"
  742     ;;
  743 
  744     gnome*)
  745     open_gnome "$url"
  746     ;;
  747 
  748     mate)
  749     open_mate "$url"
  750     ;;
  751 
  752     xfce)
  753     open_xfce "$url"
  754     ;;
  755 
  756     lxde)
  757     open_lxde "$url"
  758     ;;
  759 
  760     generic)
  761     open_generic "$url"
  762     ;;
  763 
  764     *)
  765     exit_failure_operation_impossible "no method available for opening '$url'"
  766     ;;
  767 esac