2010-06-27 22:00:20 +02:00
|
|
|
|
2024-04-16 14:51:44 +02:00
|
|
|
# shellcheck shell=bash
|
|
|
|
|
2010-06-27 22:00:20 +02:00
|
|
|
# Check for bash
|
|
|
|
[ -z "$BASH_VERSION" ] && return
|
|
|
|
|
|
|
|
####################################################################################################
|
|
|
|
|
|
|
|
__gsettings() {
|
2024-04-01 12:31:34 +02:00
|
|
|
local choices coffset schemadir=""
|
2010-10-03 08:40:48 +02:00
|
|
|
|
2024-04-16 14:58:49 +02:00
|
|
|
if [ "${COMP_CWORD}" -gt 2 ]; then
|
|
|
|
if [ "${COMP_WORDS[1]}" = --schemadir ]; then
|
2011-12-17 20:08:50 +01:00
|
|
|
# this complexity is needed to perform correct tilde expansion
|
|
|
|
schemadir=$(eval "echo --schemadir ${COMP_WORDS[2]}")
|
|
|
|
coffset=2
|
|
|
|
else
|
|
|
|
coffset=0
|
|
|
|
fi
|
|
|
|
else
|
|
|
|
coffset=0
|
|
|
|
fi
|
|
|
|
|
2024-04-16 15:03:19 +02:00
|
|
|
case "$((COMP_CWORD-coffset))" in
|
2010-10-03 08:40:48 +02:00
|
|
|
1)
|
2016-10-01 18:27:19 +02:00
|
|
|
choices=$'--schemadir\n--version\nhelp \nlist-schemas\nlist-relocatable-schemas\nlist-keys \nlist-children \nlist-recursively \nget \nrange \nset \nreset \nreset-recursively \nwritable \nmonitor \ndescribe '
|
2010-10-03 08:40:48 +02:00
|
|
|
;;
|
|
|
|
|
|
|
|
2)
|
2024-04-16 15:03:19 +02:00
|
|
|
case "${COMP_WORDS[$((coffset+1))]}" in
|
2011-12-17 20:08:50 +01:00
|
|
|
--schemadir)
|
2024-04-16 15:09:36 +02:00
|
|
|
# shellcheck disable=SC2207
|
2024-04-16 14:58:49 +02:00
|
|
|
COMPREPLY=($(compgen -o dirnames -- "${COMP_WORDS[${COMP_CWORD}]}"))
|
2011-12-17 20:08:50 +01:00
|
|
|
return 0
|
|
|
|
;;
|
|
|
|
|
2010-10-03 08:40:48 +02:00
|
|
|
help)
|
2012-05-17 06:44:36 +02:00
|
|
|
choices=$'list-schemas\nlist-relocatable-schemas\nlist-keys\nlist-children\nlist-recursively\nget\nrange\nset\nreset\nreset-recursively\nwritable\nmonitor'
|
2010-10-03 08:40:48 +02:00
|
|
|
;;
|
2012-05-17 06:44:36 +02:00
|
|
|
list-keys|list-children|list-recursively|reset-recursively)
|
2024-04-16 14:58:49 +02:00
|
|
|
choices="$(gsettings "$schemadir" list-schemas 2> /dev/null)"$'\n'"$(gsettings "$schemadir" list-relocatable-schemas 2> /dev/null | sed -e 's.$.:/.')"
|
2010-10-03 08:40:48 +02:00
|
|
|
;;
|
2018-01-05 00:45:57 +01:00
|
|
|
list-schemas)
|
2024-04-16 15:09:36 +02:00
|
|
|
# shellcheck disable=SC2207
|
2024-04-16 14:58:49 +02:00
|
|
|
COMPREPLY=($(compgen -W "--print-paths" -- "${COMP_WORDS[${COMP_CWORD}]}"))
|
2018-01-05 00:45:57 +01:00
|
|
|
return 0
|
|
|
|
;;
|
2010-10-03 08:40:48 +02:00
|
|
|
|
2016-10-01 18:27:19 +02:00
|
|
|
get|range|set|reset|writable|monitor|describe)
|
2024-04-16 14:58:49 +02:00
|
|
|
choices="$(gsettings "$schemadir" list-schemas 2> /dev/null | sed -e 's.$. .')"$'\n'"$(gsettings "$schemadir" list-relocatable-schemas 2> /dev/null | sed -e 's.$.:/.')"
|
2010-10-03 08:40:48 +02:00
|
|
|
;;
|
|
|
|
esac
|
|
|
|
;;
|
|
|
|
|
|
|
|
3)
|
2024-04-16 15:03:19 +02:00
|
|
|
case "${COMP_WORDS[$((coffset+1))]}" in
|
2010-10-03 08:40:48 +02:00
|
|
|
set)
|
2024-04-16 15:03:19 +02:00
|
|
|
choices="$(gsettings "$schemadir" list-keys "${COMP_WORDS[$((coffset+2))]}" 2> /dev/null | sed -e 's.$. .')"
|
2010-10-03 08:40:48 +02:00
|
|
|
;;
|
|
|
|
|
2016-10-01 18:27:19 +02:00
|
|
|
get|range|reset|writable|monitor|describe)
|
2024-04-16 15:03:19 +02:00
|
|
|
choices="$(gsettings "$schemadir" list-keys "${COMP_WORDS[$((coffset+2))]}" 2> /dev/null)"
|
2010-10-03 08:40:48 +02:00
|
|
|
;;
|
|
|
|
esac
|
|
|
|
;;
|
2010-10-30 07:13:42 +02:00
|
|
|
|
|
|
|
4)
|
2024-04-16 15:03:19 +02:00
|
|
|
case "${COMP_WORDS[$((coffset+2))]}" in
|
2010-10-30 07:13:42 +02:00
|
|
|
set)
|
2024-04-16 15:09:36 +02:00
|
|
|
# shellcheck disable=SC2207
|
2024-04-16 15:03:19 +02:00
|
|
|
range=($(gsettings "$schemadir" range "${COMP_WORDS[$((coffset+2))]}" "${COMP_WORDS[$((coffset+3))]}" 2> /dev/null))
|
2010-10-30 07:13:42 +02:00
|
|
|
case "${range[0]}" in
|
|
|
|
enum)
|
2024-04-16 15:08:39 +02:00
|
|
|
unset 'range[0]'
|
2010-10-30 07:13:42 +02:00
|
|
|
;;
|
|
|
|
*)
|
|
|
|
unset range
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
local IFS=$'\n'
|
|
|
|
choices="${range[*]}"
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
;;
|
2010-10-03 08:40:48 +02:00
|
|
|
esac
|
|
|
|
|
|
|
|
local IFS=$'\n'
|
2024-04-16 15:09:36 +02:00
|
|
|
# shellcheck disable=SC2207
|
2011-12-17 20:08:50 +01:00
|
|
|
COMPREPLY=($(compgen -W "${choices}" -- "${COMP_WORDS[${COMP_CWORD}]}"))
|
2010-06-27 22:00:20 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
####################################################################################################
|
|
|
|
|
|
|
|
complete -o nospace -F __gsettings gsettings
|