summaryrefslogtreecommitdiff
path: root/tools/mate-gsettings-toggle
blob: f6500734d9f83f243e615375b43eef263fcf96c5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
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