Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(3)

Unified Diff: third_party/xdg-utils/scripts/xdg-open

Issue 3273010: Update our copy of xdg-utils to 2010-08-30, and include a patched xdg-mime. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/deps/
Patch Set: Created 10 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « third_party/xdg-utils/scripts/xdg-mime.in ('k') | third_party/xdg-utils/scripts/xdg-open.in » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/xdg-utils/scripts/xdg-open
===================================================================
--- third_party/xdg-utils/scripts/xdg-open (revision 57942)
+++ third_party/xdg-utils/scripts/xdg-open (working copy)
@@ -1,4 +1,4 @@
-#!/bin/bash
+#!/bin/sh
#---------------------------------------------
# xdg-open
#
@@ -200,7 +200,7 @@
}
#------------------------------------------------------------
-# Exit script on insufficient permission to read a specified file
+# Exit script on insufficient permission to write a specified file
exit_failure_file_permission_write()
{
@@ -277,7 +277,7 @@
;;
--version)
- echo "xdg-open 1.0.1"
+ echo "xdg-open 1.0.2"
exit_success
;;
esac
@@ -303,7 +303,8 @@
{
if [ x"$KDE_FULL_SESSION" = x"true" ]; then DE=kde;
elif [ x"$GNOME_DESKTOP_SESSION_ID" != x"" ]; then DE=gnome;
- elif xprop -root _DT_SAVE_MODE | grep ' = \"xfce4\"$' >/dev/null 2>&1; then DE=xfce;
+ 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;
+ elif xprop -root _DT_SAVE_MODE 2> /dev/null | grep ' = \"xfce4\"$' >/dev/null 2>&1; then DE=xfce;
fi
}
@@ -324,10 +325,25 @@
return 0
}
+# This handles backslashes but not quote marks.
+first_word()
+{
+ read first rest
+ echo "$first"
+}
+
open_kde()
{
- kfmclient exec "$1"
- kfmclient_fix_exit_code $?
+ if kde-open -v 2>/dev/null 1>&2; then
+ kde-open "$1"
+ else
+ if [ x"$KDE_SESSION_VERSION" = x"4" ]; then
+ kfmclient openURL "$1"
+ else
+ kfmclient exec "$1"
+ kfmclient_fix_exit_code $?
+ fi
+ fi
if [ $? -eq 0 ]; then
exit_success
@@ -338,7 +354,11 @@
open_gnome()
{
- gnome-open "$1"
+ if gvfs-open --help 2>/dev/null 1>&2; then
+ gvfs-open "$1"
+ else
+ gnome-open "$1"
+ fi
if [ $? -eq 0 ]; then
exit_success
@@ -358,38 +378,80 @@
fi
}
-open_generic()
+open_generic_xdg_mime()
{
- if mimeopen -v 2>/dev/null 1>&2; then
- mimeopen -n "$1"
- if [ $? -eq 0 ]; then
- exit_success
- fi
+ filetype=`xdg-mime query filetype "$1" | sed "s/;.*//"`
+ default=`xdg-mime query default "$filetype"`
+ if [ -n "$default" ] ; then
+ xdg_user_dir="$XDG_DATA_HOME"
+ [ -n "$xdg_user_dir" ] || xdg_user_dir="$HOME/.local/share"
+
+ 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
+ file="$x/applications/$default"
+ if [ -r "$file" ] ; then
+ command="`grep -E "^Exec(\[[^]=]*])?=" "$file" | cut -d= -f 2- | first_word`"
+ command_exec=`which $command 2>/dev/null`
+ if [ -x "$command_exec" ] ; then
+ $command_exec "$1"
+ if [ $? -eq 0 ]; then
+ exit_success
+ fi
+ fi
+ fi
+ done
fi
+}
- if which run-mailcap 2>/dev/null 1>&2 &&
- (echo "$1" | grep -q '^file://' ||
+open_generic()
+{
+ # Paths or file:// URLs
+ if (echo "$1" | grep -q '^file://' ||
! echo "$1" | egrep -q '^[a-zA-Z+\.\-]+:'); then
local file=$(echo "$1" | sed 's%^file://%%')
- run-mailcap --action=view "$file"
- if [ $? -eq 0 ]; then
- exit_success
+
+ # Decode URLs
+ # TODO
+
+ check_input_file "$file"
+
+ open_generic_xdg_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
+ fi
fi
+
+ if mimeopen -v 2>/dev/null 1>&2; then
+ mimeopen -L -n "$file"
+ if [ $? -eq 0 ]; then
+ exit_success
+ fi
+ fi
fi
IFS=":"
for browser in $BROWSER; do
if [ x"$browser" != x"" ]; then
- IFS=' '
- browser_with_arg=${browser//'%s'/"$1"}
+ browser_with_arg=`printf "$browser" "$1" 2>/dev/null`
+ if [ $? -ne 0 ]; then
+ browser_with_arg=$browser;
+ fi
- if [ x"$browser_with_arg" = x"$browser" ]; then "$browser" "$1";
- else $browser_with_arg;
+ if [ x"$browser_with_arg" = x"$browser" ]; then
+ "$browser" "$1";
+ else eval '$browser_with_arg'$xdg_redirect_output;
fi
- if [ $? -eq 0 ]; then exit_success;
+ if [ $? -eq 0 ]; then
+ exit_success;
fi
fi
done
@@ -425,13 +487,17 @@
detectDE
if [ x"$DE" = x"" ]; then
- # if BROWSER variable is not set, check some well known browsers instead
- if [ x"$BROWSER" = x"" ]; then
- BROWSER=firefox:mozilla:netscape
- fi
DE=generic
fi
+# if BROWSER variable is not set, check some well known browsers instead
+if [ x"$BROWSER" = x"" ]; then
+ BROWSER=links2:links:lynx:w3m
+ if [ -n "$DISPLAY" ]; then
+ BROWSER=firefox:mozilla:epiphany:konqueror:chromium-browser:google-chrome:$BROWSER
+ fi
+fi
+
case "$DE" in
kde)
open_kde "$url"
« no previous file with comments | « third_party/xdg-utils/scripts/xdg-mime.in ('k') | third_party/xdg-utils/scripts/xdg-open.in » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698