summaryrefslogtreecommitdiff
path: root/tools/mate-gsettings-toggle
diff options
context:
space:
mode:
authorinfirit <[email protected]>2013-09-20 22:57:31 +0200
committerStefano Karapetsas <[email protected]>2013-10-03 14:18:42 +0200
commit08b894ae5dcd858e356be6bd396b05b1cd718f3d (patch)
treebe14ec620a7fa56798702be52419c3cdf09bdfe3 /tools/mate-gsettings-toggle
parent87189aed6643f06e7e7090bfb61e01e614677886 (diff)
downloadmate-desktop-08b894ae5dcd858e356be6bd396b05b1cd718f3d.tar.bz2
mate-desktop-08b894ae5dcd858e356be6bd396b05b1cd718f3d.tar.xz
Add mate-gsettings-toggle.sh
Merged also Makefile.am and configure.ac
Diffstat (limited to 'tools/mate-gsettings-toggle')
-rwxr-xr-xtools/mate-gsettings-toggle48
1 files changed, 48 insertions, 0 deletions
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
+