diff --git a/scripts/xdg-open.in b/scripts/xdg-open.in index d48afb2..bf49d4a 100644 --- a/scripts/xdg-open.in +++ b/scripts/xdg-open.in @@ -84,7 +84,7 @@ open_xfce() open_generic_xdg_mime() { - filetype=`xdg-mime query filetype "$1" | sed "s/;.*//"` + filetype="$2" default=`xdg-mime query default "$filetype"` if [ -n "$default" ] ; then xdg_user_dir="$XDG_DATA_HOME" @@ -93,6 +93,7 @@ open_generic_xdg_mime() xdg_system_dirs="$XDG_DATA_DIRS" [ -n "$xdg_system_dirs" ] || xdg_system_dirs=/usr/local/share/:/usr/share/ +DEBUG 3 "$xdg_user_dir:$xdg_system_dirs" for x in `echo "$xdg_user_dir:$xdg_system_dirs" | sed 's/:/ /g'`; do local file="$x/applications/$default" if [ -r "$file" ] ; then @@ -109,6 +110,21 @@ open_generic_xdg_mime() fi } +open_generic_xdg_file_mime() +{ + filetype=`xdg-mime query filetype "$1" | sed "s/;.*//"` + open_generic_xdg_mime "$1" "$filetype" +} + +open_generic_xdg_uri_mime() +{ + scheme="`echo $1 | sed -n 's/\(^[[:alnum:]+\.-]*\):.*$/\1/p'`" + if [ -n $scheme ]; then + filetype="uri/$scheme" + open_generic_xdg_mime "$1" "$filetype" + fi +} + open_generic() { # Paths or file:// URLs @@ -124,7 +140,7 @@ open_generic() fi check_input_file "$file" - open_generic_xdg_mime "$file" + open_generic_xdg_file_mime "$file" if [ -f /etc/debian_version ] && which run-mailcap 2>/dev/null 1>&2; then @@ -142,6 +158,8 @@ open_generic() fi fi + open_generic_xdg_uri_mime "$1" + IFS=":" for browser in $BROWSER; do if [ x"$browser" != x"" ]; then