Index: third_party/xdg-utils/scripts/xdg-settings.in |
=================================================================== |
--- third_party/xdg-utils/scripts/xdg-settings.in (revision 79890) |
+++ third_party/xdg-utils/scripts/xdg-settings.in (working copy) |
@@ -107,21 +107,26 @@ |
# This function is hard-coded for text/html but it could be adapted if needed. |
fix_local_desktop_file() |
{ |
+ if test -z "$2" ; then |
+ MIME="text/html" |
+ else |
+ MIME="$2" |
+ fi |
apps="${XDG_DATA_HOME:-$HOME/.local/share}/applications" |
# No local desktop file? |
[ ! -f "$apps/$1" ] && return |
- MIME="`grep "^MimeType=" "$apps/$1" | cut -d= -f 2-`" |
- case "$MIME" in |
- text/html\;*|*\;text/html\;*|*\;text/html\;|*\;text/html) |
- # Already has text/html? Great! |
+ MIMETYPES="`grep "^MimeType=" "$apps/$1" | cut -d= -f 2-`" |
+ case "$MIMETYPES" in |
+ $MIME\;*|*\;$MIME\;*|*\;$MIME\;|*\;$MIME) |
+ # Already has the mime-type? Great! |
return 0 |
;; |
esac |
- # Add text/html to the list |
+ # Add the mime-type to the list |
temp="`mktemp "$apps/$1.XXXXXX"`" || return |
grep -v "^MimeType=" "$apps/$1" >> "$temp" |
- echo "MimeType=text/html;$MIME" >> "$temp" |
+ echo "MimeType=$MIME;$MIMETYPES" >> "$temp" |
oldlines="`wc -l < "$apps/$1"`" |
newlines="`wc -l < "$temp"`" |
@@ -155,22 +160,32 @@ |
get_browser_mime() |
{ |
+ if test -z "$1" ; then |
+ MIME="text/html" |
+ else |
+ MIME="$1" |
+ fi |
xdg_mime_fixup |
- xdg-mime query default text/html |
+ xdg-mime query default "$MIME" |
} |
set_browser_mime() |
{ |
xdg_mime_fixup |
- orig="`get_browser_mime`" |
+ if test -z "$2" ; then |
+ MIME="text/html" |
+ else |
+ MIME="$2" |
+ fi |
+ orig="`get_browser_mime $MIME`" |
# Fixing the local desktop file can actually change the default browser all |
# by itself, so we fix it only after querying to find the current default. |
- fix_local_desktop_file "$1" || return |
+ fix_local_desktop_file "$1" "$MIME" || return |
mkdir -p "${XDG_DATA_HOME:-$HOME/.local/share}/applications" |
- xdg-mime default "$1" text/html || return |
+ xdg-mime default "$1" "$MIME" || return |
if [ x"`get_browser_mime`" != x"$1" ]; then |
# Put back the original value |
- xdg-mime default "$orig" text/html |
+ xdg-mime default "$orig" "$MIME" |
exit_failure_operation_failed |
fi |
} |
@@ -340,6 +355,45 @@ |
} |
# }}} GNOME |
+# {{{ GNOME 3.x |
+ |
+get_browser_gnome3() |
+{ |
+ get_browser_mime "x-scheme-handler/http" |
+} |
+ |
+check_browser_gnome3() |
+{ |
+ desktop="$1" |
+ check="`desktop_file_to_binary "$1"`" |
+ if [ -z "$check" ]; then |
+ echo no |
+ exit_success |
+ fi |
+ # Check HTTP and HTTPS, but not about: and unknown:. |
+ for protocol in http https; do |
+ browser="`get_browser_mime "x-scheme-handler/$protocol"`" |
+ if [ x"$browser" != x"$desktop" ]; then |
+ echo no |
+ exit_success |
+ fi |
+ done |
+ echo yes |
+ exit_success |
+} |
+ |
+set_browser_gnome3() |
+{ |
+ binary="`desktop_file_to_binary "$1"`" |
+ [ "$binary" ] || exit_failure_file_missing |
+ set_browser_mime "$1" || return |
+ |
+ # Set the default browser. |
+ for protocol in http https about unknown; do |
+ set_browser_mime "$1" "x-scheme-handler/$protocol" || return |
+ done |
+} |
+# }}} GNOME 3.x |
# {{{ xfce |
get_browser_xfce() |
@@ -549,7 +603,7 @@ |
detectDE |
case "$DE" in |
- kde|gnome|xfce) |
+ kde|gnome*|xfce) |
dispatch_specific "$@" |
;; |