--- xdg-open.orig 2009-11-04 21:47:58.168292802 -0800 +++ xdg-open 2009-11-04 21:47:50.118295119 -0800 @@ -360,6 +360,32 @@ open_generic() { + MIME_TYPE=`xdg-mime query filetype "$1" | sed "s/;.*//"` + DEFAULT=`xdg-mime query default "$MIME_TYPE"` + if [ -n "$DEFAULT" ] ; then + xdg_user_dir="$XDG_DATA_HOME" + [ -n "$xdg_user_dir" ] || xdg_user_dir="$HOME/.local/share" + xdg_user_dir="$xdg_user_dir/$xdg_dir_name" + xdg_system_dirs="$XDG_DATA_DIRS" + [ -n "$xdg_system_dirs" ] || xdg_system_dirs=/usr/local/share/:/usr/share/ + + for x in `echo "$xdg_user_dir:$xdg_system_dirs" | sed 's/:/ /g'`; do + if [ -r "$x/applications/$DEFAULT" ] ; then + DEFAULT="`grep "Exec=" "$x/applications/$DEFAULT" | sed "s/Exec=//"`" + if which "`echo $DEFAULT | cut -d ' ' -f 1`" &> /dev/null ; then + break + fi + fi + done + if which "`echo $DEFAULT | cut -d ' ' -f 1`" &> /dev/null ; then + $DEFAULT "$1" + if [ $? -eq 0 ]; then + exit_success + else + exit_failure_operation_failed + fi + fi + fi IFS=":" for browser in $BROWSER; do if [ x"$browser" != x"" ]; then