summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorinfirit <[email protected]>2013-09-20 22:57:31 +0200
committerinfirit <[email protected]>2013-09-21 08:14:15 +0200
commit25370817dd2c2b50281569c6d81dc6a20f468b97 (patch)
treeba1398056e271bc740073393f4a64bc3d0d161a6
parent49000652ee447c377bf2c8cb7c4cd8db47b7698a (diff)
downloadmate-desktop-25370817dd2c2b50281569c6d81dc6a20f468b97.tar.bz2
mate-desktop-25370817dd2c2b50281569c6d81dc6a20f468b97.tar.xz
Add mate-gsettings-toggle.sh
-rw-r--r--Makefile.am5
-rw-r--r--configure.ac1
-rw-r--r--tools/Makefile.am3
-rwxr-xr-xtools/mate-gsettings-toggle48
4 files changed, 55 insertions, 2 deletions
diff --git a/Makefile.am b/Makefile.am
index 3283061..701a69a 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -1,4 +1,4 @@
-SUBDIRS = libmate-desktop man docs po schemas
+SUBDIRS = libmate-desktop man docs po schemas tools
if MATE_ABOUT_ENABLED
SUBDIRS += mate-about
@@ -26,7 +26,8 @@ EXTRA_DIST = \
HACKING \
MAINTAINERS \
mate-version.xml.in.in \
- mate-doc-utils.make
+ mate-doc-utils.make \
+ tools/mate-gsettings-toggle
CLEANFILES = \
$(version_DATA)
diff --git a/configure.ac b/configure.ac
index eea5093..6338988 100644
--- a/configure.ac
+++ b/configure.ac
@@ -309,6 +309,7 @@ schemas/Makefile
man/Makefile
mate-conf/Makefile
mate-conf/mate-conf-import.desktop.in
+tools/Makefile
])
AC_OUTPUT
diff --git a/tools/Makefile.am b/tools/Makefile.am
new file mode 100644
index 0000000..399fb83
--- /dev/null
+++ b/tools/Makefile.am
@@ -0,0 +1,3 @@
+bin_SCRIPTS = mate-gsettings-toggle.sh
+
+EXTRA_DIST = $(bin_SCRIPTS)
diff --git a/tools/mate-gsettings-toggle b/tools/mate-gsettings-toggle
new file mode 100755
index 0000000..f650073
--- /dev/null
+++ b/tools/mate-gsettings-toggle
@@ -0,0 +1,48 @@
+#!/usr/bin/env sh
+
+SCHEMA="org.mate.applications-at"
+KEYS="screen-keyboard-enabled screen-magnifier-enabled screen-reader-enabled"
+GSETTINGS="$(which gsettings 2> /dev/null)"
+
+if [ "${?}" != "0" ]; then
+ printf "gsettings command not found....\n"
+ printf "please install gsettings which is part of glib\n"
+ exit 1
+fi
+
+found="0"
+for key in ${KEYS}; do
+ if [ "${key}" = "${1}" ]; then
+ found="1"
+ fi
+done
+
+if [ "${found}" = "0" ]; then
+ printf "Invalid key \"${1}\", should be one of:\n"
+ printf "${KEYS}\n"
+ exit 1
+fi
+
+curval=$(eval "${GSETTINGS} get ${SCHEMA} ${1}")
+
+case ${curval} in
+"false")
+ $(eval "${GSETTINGS} set ${SCHEMA} ${1} 'true'")
+ if [ "${?}" = "0" ]; then
+ printf "Toggle true\n"
+ exit 0
+ else
+ printf "Something went wrong: got exit status ${?}\n"
+ exit 1
+ fi;;
+"true")
+ $(eval "${GSETTINGS} set ${SCHEMA} ${1} 'false'")
+ if [ "${?}" = "0" ]; then
+ printf "Toggle false\n"
+ exit 0
+ else
+ printf "Something went wrong: got exit status ${?}\n"
+ exit 1
+ fi;;
+esac
+