Created
April 14, 2015 19:22
-
-
Save rfc1459/53c2b4c884810d331b38 to your computer and use it in GitHub Desktop.
Patch for xdg-utils/MATE 1.8 on Ubuntu Trusty
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Description: Let xdg-utils know about MATE 1.8 | |
Author: Matteo Panella <[email protected]> | |
Bug-Ubuntu: https://launchpad.net/bugs/1001902 | |
--- a/scripts/xdg-open | |
+++ b/scripts/xdg-open | |
@@ -308,6 +308,8 @@ detectDE() | |
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; | |
elif [ x"$DESKTOP_SESSION" = x"LXDE" ]; then DE=lxde; | |
+ elif [ x"$XDG_CURRENT_DESKTOP" = x"MATE" ]; then DE=mate; | |
+ elif [ x"$DESKTOP_SESSION" = x"mate" ]; then DE=mate; | |
else DE="" | |
fi | |
} | |
@@ -371,6 +373,22 @@ open_gnome() | |
fi | |
} | |
+ | |
+open_mate() | |
+{ | |
+ if gvfs-open --help 2>/dev/null 1>&2; then | |
+ gvfs-open "$1" | |
+ else | |
+ mate-open "$1" | |
+ fi | |
+ | |
+ if [ $? -eq 0 ]; then | |
+ exit_success | |
+ else | |
+ exit_failure_operation_failed | |
+ fi | |
+} | |
+ | |
open_xfce() | |
{ | |
exo-open "$1" | |
@@ -545,6 +563,10 @@ case "$DE" in | |
open_gnome "$url" | |
;; | |
+ mate) | |
+ open_mate "$url" | |
+ ;; | |
+ | |
xfce) | |
open_xfce "$url" | |
;; | |
--- a/scripts/xdg-email | |
+++ b/scripts/xdg-email | |
@@ -381,6 +381,8 @@ detectDE() | |
elif xprop -root _DT_SAVE_MODE 2> /dev/null | grep ' = \"xfce4\"$' >/dev/null 2>&1; then DE=xfce; | |
elif [ x"$DESKTOP_SESSION" = x"LXDE" ]; then DE=lxde; | |
elif [ x"$XDG_CURRENT_DESKTOP" = x"LXDE" ]; then DE=lxde; | |
+ elif [ x"$XDG_CURRENT_DESKTOP" = x"MATE" ]; then DE=mate; | |
+ elif [ x"$DESKTOP_SESSION" = x"mate" ]; then DE=mate; | |
elif [ -r ~/.muttrc ] && which mutt > /dev/null 2>&1; then | |
DE=envvar | |
MAILER="x-terminal-emulator -e mutt" | |
@@ -533,6 +535,31 @@ open_gnome() | |
fi | |
} | |
+open_mate() | |
+{ | |
+ local client | |
+ local desktop | |
+ desktop=`xdg-mime query default "x-scheme-handler/mailto"` | |
+ client=`desktop_file_to_binary "$browser"` | |
+ echo $client | grep thunderbird > /dev/null 2>&1 | |
+ if [ $? -eq 0 ] ; then | |
+ run_thunderbird "$client" "$1" | |
+ fi | |
+ | |
+ if gvfs-open --help 2>/dev/null 1>&2; then | |
+ DEBUG 1 "Running gvfs-open \"$1\"" | |
+ gvfs-open "$1" | |
+ else | |
+ DEBUG 1 "Running mate-open \"$1\"" | |
+ mate-open "$1" | |
+ fi | |
+ | |
+ if [ $? -eq 0 ]; then | |
+ exit_success | |
+ else | |
+ exit_failure_operation_failed | |
+ fi | |
+} | |
open_xfce() | |
{ | |
@@ -803,6 +830,10 @@ case "$DE" in | |
open_gnome "${mailto}" | |
;; | |
+ mate) | |
+ open_mate "${mailto}" | |
+ ;; | |
+ | |
xfce) | |
open_xfce "${mailto}" | |
;; | |
--- a/scripts/xdg-screensaver | |
+++ b/scripts/xdg-screensaver | |
@@ -336,6 +336,8 @@ detectDE() | |
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; | |
elif [ x"$DESKTOP_SESSION" = x"LXDE" ]; then DE=lxde; | |
+ elif [ x"$XDG_CURRENT_DESKTOP" = x"MATE" ]; then DE=mate; | |
+ elif [ x"$DESKTOP_SESSION" = x"mate" ]; then DE=mate; | |
else DE="" | |
fi | |
} | |
@@ -428,6 +430,10 @@ perform_action() | |
screensaver_gnome_screensaver "$1" | |
;; | |
+ mate_screensaver) | |
+ screensaver_mate_screensaver "$1" | |
+ ;; | |
+ | |
xscreensaver) | |
screensaver_xscreensaver "$1" | |
;; | |
@@ -882,6 +888,82 @@ screensaver_gnome_screensaver() | |
esac | |
} | |
+screensaver_mate_screensaver() | |
+{ | |
+# DBUS interface for mate-screensaver | |
+# This is same as gnome's for now but may change in the future as MATE | |
+# does not follow gnome's developement. | |
+ case "$1" in | |
+ suspend) | |
+ screensaver_suspend_loop \ | |
+ dbus-send --session \ | |
+ --dest=org.mate.ScreenSaver \ | |
+ --type=method_call \ | |
+ /org/mate/ScreenSaver \ | |
+ org.mate.ScreenSaver.SimulateUserActivity \ | |
+ 2> /dev/null | |
+ result=$? | |
+ ;; | |
+ | |
+ resume) | |
+ # Automatic resume when $screensaver_file disappears | |
+ result=0 | |
+ ;; | |
+ | |
+ activate) | |
+ dbus-send --session \ | |
+ --dest=org.mate.ScreenSaver \ | |
+ --type=method_call \ | |
+ /org/mate/ScreenSaver \ | |
+ org.mate.ScreenSaver.SetActive \ | |
+ boolean:true \ | |
+ 2> /dev/null | |
+ result=$? | |
+ ;; | |
+ | |
+ lock) | |
+ mate-screensaver-command --lock > /dev/null 2> /dev/null | |
+ result=$? | |
+ ;; | |
+ | |
+ reset) | |
+ # Turns the screensaver off right now | |
+ dbus-send --session \ | |
+ --dest=org.mate.ScreenSaver \ | |
+ --type=method_call \ | |
+ /org/mate/ScreenSaver \ | |
+ org.mate.ScreenSaver.SimulateUserActivity \ | |
+ 2> /dev/null | |
+ result=$? | |
+ ;; | |
+ | |
+ status) | |
+ status=`dbus-send --session \ | |
+ --dest=org.mate.ScreenSaver \ | |
+ --type=method_call \ | |
+ --print-reply \ | |
+ --reply-timeout=2000 \ | |
+ /org/mate/ScreenSaver \ | |
+ org.mate.ScreenSaver.GetActive \ | |
+ | grep boolean | cut -d ' ' -f 5` | |
+ result=$? | |
+ if [ x"$status" = "xtrue" -o x"$status" = "xfalse" ]; then | |
+ echo "enabled" | |
+ elif [ x"$result" != "x0" ]; then | |
+ echo "ERROR: dbus org.mate.ScreenSaver.GetActive returned '$status'" >&2 | |
+ return 1 | |
+ else | |
+ echo "disabled" | |
+ fi | |
+ ;; | |
+ | |
+ *) | |
+ echo "ERROR: Unknown command '$1" >&2 | |
+ return 1 | |
+ ;; | |
+ esac | |
+} | |
+ | |
screensaver_xscreensaver() | |
{ | |
case "$1" in | |
@@ -985,6 +1067,8 @@ detectDE | |
xscreensaver-command -version 2> /dev/null | grep XScreenSaver > /dev/null && DE="xscreensaver" | |
# Consider "gnome-screensaver" a separate DE | |
gnome-screensaver-command -q > /dev/null 2>&1 && DE="gnome_screensaver" | |
+# Consider "mate-screensaver" a separate DE | |
+mate-screensaver-command -q > /dev/null 2>&1 && DE="mate_screensaver" | |
if [ "$action" = "resume" ] ; then | |
do_resume | |
--- a/scripts/xdg-mime | |
+++ b/scripts/xdg-mime | |
@@ -432,6 +432,8 @@ detectDE() | |
elif xprop -root _DT_SAVE_MODE 2> /dev/null | grep ' = \"xfce4\"$' >/dev/null 2>&1; then DE=xfce; | |
elif [ x"$DESKTOP_SESSION" = x"LXDE" ]; then DE=lxde; | |
elif [ x"XDG_CURRENT_DESKTOP" = x"LXDE" ]; then DE=lxde; | |
+ elif [ x"$XDG_CURRENT_DESKTOP" = x"MATE" ]; then DE=mate; | |
+ elif [ x"$DESKTOP_SESSION" = x"mate" ]; then DE=mate; | |
else DE="" | |
fi | |
} | |
@@ -517,6 +519,26 @@ info_gnome() | |
fi | |
} | |
+info_mate() | |
+{ | |
+ if gvfs-info --help 2>/dev/null 1>&2; then | |
+ DEBUG 1 "Running gvfs-info \"$1\"" | |
+ gvfs-info "$1" 2> /dev/null | grep standard::content-type | cut -d' ' -f4 | |
+ elif mimetype --version >/dev/null 2>&1; then | |
+ DEBUG 1 "Running mimetype -b \"$1\"" | |
+ mimetype -b "$1" | |
+ else | |
+ DEBUG 1 "Running file -i \"$1\"" | |
+ /usr/bin/file -i "$1" 2> /dev/null | cut -d ":" -f 2 | sed s/"^ "// | |
+ fi | |
+ | |
+ if [ $? -eq 0 ]; then | |
+ exit_success | |
+ else | |
+ exit_failure_operation_failed | |
+ fi | |
+} | |
+ | |
info_generic() | |
{ | |
if mimetype --version >/dev/null 2>&1; then | |
@@ -930,6 +952,10 @@ if [ "$action" = "info" ]; then | |
info_gnome "$filename" | |
;; | |
+ mate) | |
+ info_mate "$filename" | |
+ ;; | |
+ | |
*) | |
info_generic "$filename" | |
;; | |
--- a/scripts/xdg-settings | |
+++ b/scripts/xdg-settings | |
@@ -316,6 +316,8 @@ detectDE() | |
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; | |
elif [ x"$DESKTOP_SESSION" = x"LXDE" ]; then DE=lxde; | |
+ elif [ x"$XDG_CURRENT_DESKTOP" = x"MATE" ]; then DE=mate; | |
+ elif [ x"$DESKTOP_SESSION" = x"mate" ]; then DE=mate; | |
else DE="" | |
fi | |
} | |
@@ -671,6 +673,46 @@ set_browser_gnome() | |
} | |
# }}} GNOME | |
+# {{{ MATE | |
+ | |
+get_browser_mate() | |
+{ | |
+ get_browser_mime "x-scheme-handler/http" | |
+} | |
+ | |
+check_browser_mate() | |
+{ | |
+ 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:, using the MATE scheme. | |
+ 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_mate() | |
+{ | |
+ binary="`desktop_file_to_binary "$1"`" | |
+ [ "$binary" ] || exit_failure_file_missing | |
+ set_browser_mime "$1" || return | |
+ | |
+ # Set the default browser using the MATE scheme. | |
+ for protocol in http https about unknown; do | |
+ set_browser_mime "$1" "x-scheme-handler/$protocol" || return | |
+ done | |
+} | |
+ | |
+# }}} MATE | |
# {{{ xfce | |
get_browser_xfce() | |
@@ -880,7 +922,7 @@ fi | |
detectDE | |
case "$DE" in | |
- kde|gnome|xfce) | |
+ kde|gnome|mate|xfce) | |
dispatch_specific "$@" | |
;; | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment