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

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

Issue 151098: Patch from mdm@google.com... (Closed) Base URL: svn://chrome-svn/chrome/trunk/deps/
Patch Set: Created 11 years, 6 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-open ('k') | third_party/xdg-utils/scripts/xdg-screensaver » ('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.in
===================================================================
--- third_party/xdg-utils/scripts/xdg-open.in (revision 0)
+++ third_party/xdg-utils/scripts/xdg-open.in (revision 0)
@@ -0,0 +1,158 @@
+#!/bin/bash
+#---------------------------------------------
+# xdg-open
+#
+# Utility script to open a URL in the registered default application.
+#
+# Refer to the usage() function below for usage.
+#
+# Copyright 2006, Kevin Krammer <kevin.krammer@gmx.at>
+# Copyright 2006, Jeremy White <jwhite@codeweavers.com>
+#
+# LICENSE:
+#
+#---------------------------------------------
+
+manualpage()
+{
+cat << _MANUALPAGE
+_MANUALPAGE
+}
+
+usage()
+{
+cat << _USAGE
+_USAGE
+}
+
+#@xdg-utils-common@
+
+open_kde()
+{
+ kfmclient exec "$1"
+ kfmclient_fix_exit_code $?
+
+ if [ $? -eq 0 ]; then
+ exit_success
+ else
+ exit_failure_operation_failed
+ fi
+}
+
+open_gnome()
+{
+ gnome-open "$1"
+
+ if [ $? -eq 0 ]; then
+ exit_success
+ else
+ exit_failure_operation_failed
+ fi
+}
+
+open_xfce()
+{
+ exo-open "$1"
+
+ if [ $? -eq 0 ]; then
+ exit_success
+ else
+ exit_failure_operation_failed
+ fi
+}
+
+open_generic()
+{
+ if mimeopen -v 2>/dev/null 1>&2; then
+ mimeopen -n "$1"
+ if [ $? -eq 0 ]; then
+ exit_success
+ fi
+ fi
+
+ if which run-mailcap 2>/dev/null 1>&2 &&
+ (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
+ fi
+ fi
+
+ IFS=":"
+ for browser in $BROWSER; do
+ if [ x"$browser" != x"" ]; then
+
+ IFS=' '
+ browser_with_arg=${browser//'%s'/"$1"}
+
+ if [ x"$browser_with_arg" = x"$browser" ]; then "$browser" "$1";
+ else $browser_with_arg;
+ fi
+
+ if [ $? -eq 0 ]; then exit_success;
+ fi
+ fi
+ done
+
+ exit_failure_operation_impossible "no method available for opening '$1'"
+}
+
+[ x"$1" != x"" ] || exit_failure_syntax
+
+url=
+while [ $# -gt 0 ] ; do
+ parm="$1"
+ shift
+
+ case "$parm" in
+ -*)
+ exit_failure_syntax "unexpected option '$parm'"
+ ;;
+
+ *)
+ if [ -n "$url" ] ; then
+ exit_failure_syntax "unexpected argument '$parm'"
+ fi
+ url="$parm"
+ ;;
+ esac
+done
+
+if [ -z "${url}" ] ; then
+ exit_failure_syntax "file or URL argument missing"
+fi
+
+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
+
+case "$DE" in
+ kde)
+ open_kde "$url"
+ ;;
+
+ gnome)
+ open_gnome "$url"
+ ;;
+
+ xfce)
+ open_xfce "$url"
+ ;;
+
+ generic)
+ open_generic "$url"
+ ;;
+
+ *)
+ exit_failure_operation_impossible "no method available for opening '$url'"
+ ;;
+esac
« no previous file with comments | « third_party/xdg-utils/scripts/xdg-open ('k') | third_party/xdg-utils/scripts/xdg-screensaver » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698