xdg-utils (1.1.0~rc1+git20111210-6) no-X.diff

Summary

 scripts/xdg-email.in |    2 +-
 scripts/xdg-open.in  |   33 +++++++++++++++++++++------------
 2 files changed, 22 insertions(+), 13 deletions(-)

    
download this patch

Patch contents

--- a/scripts/xdg-open.in
+++ b/scripts/xdg-open.in
@@ -191,25 +191,29 @@ open_generic()
         fi
         check_input_file "$file"
 
-        open_generic_xdg_file_mime "$file"
+        if [ -n "$DISPLAY" ]; then
+            open_generic_xdg_file_mime "$file"
 
-        if [ -f /etc/debian_version ] &&
-            which run-mailcap 2>/dev/null 1>&2; then
-            run-mailcap --action=view "$file"
-            if [ $? -eq 0 ]; then
-                exit_success
+            if mimeopen -v 2>/dev/null 1>&2; then
+                mimeopen -L -n "$file"
+                if [ $? -eq 0 ]; then
+                    exit_success
+                fi
             fi
         fi
 
-        if mimeopen -v 2>/dev/null 1>&2; then
-            mimeopen -L -n "$file"
+        if [ -f /etc/debian_version ] &&
+            which run-mailcap 2>/dev/null 1>&2; then
+            run-mailcap --action=view "$file"
             if [ $? -eq 0 ]; then
                 exit_success
             fi
         fi
     fi
 
-    open_generic_xdg_x_scheme_handler "$1"
+    if [ -n "$DISPLAY" ]; then
+        open_generic_xdg_x_scheme_handler "$1"
+    fi
 
     OLDIFS="$IFS"
     IFS=":"
@@ -222,9 +226,14 @@ open_generic()
                 browser_with_arg=$browser;
             fi
 
+            local redirect_output=''
+            if [ -n "$DISPLAY" ]; then
+                redirect_output="$xdg_redirect_output"
+            fi
+
             if [ x"$browser_with_arg" = x"$browser" ]; then
-                eval '$browser $1'$xdg_redirect_output;
-            else eval '$browser_with_arg'$xdg_redirect_output;
+                eval '$browser $1'$redirect_output;
+            else eval '$browser_with_arg'$redirect_output;
             fi
 
             if [ $? -eq 0 ]; then
@@ -297,7 +306,7 @@ DEBUG 2 "Selected DE $DE"
 
 # if BROWSER variable is not set, check some well known browsers instead
 if [ x"$BROWSER" = x"" ]; then
-    BROWSER=links2:elinks:links:lynx:w3m
+    BROWSER=www-browser:links2:elinks:links:lynx:w3m
     if [ -n "$DISPLAY" ]; then
         BROWSER=x-www-browser:firefox:seamonkey:mozilla:epiphany:konqueror:chromium-browser:google-chrome:$BROWSER
     fi
--- a/scripts/xdg-email.in
+++ b/scripts/xdg-email.in
@@ -405,7 +405,7 @@ fi
 
 # if BROWSER variable is not set, check some well known browsers instead
 if [ x"$BROWSER" = x"" ]; then
-    BROWSER=links2:elinks:links:lynx:w3m
+    BROWSER=www-browser:links2:elinks:links:lynx:w3m
     if [ -n "$DISPLAY" ]; then
         BROWSER=x-www-browser:firefox:seamonkey:mozilla:epiphany:konqueror:chromium-browser:google-chrome:$BROWSER
     fi