2010-06-27 22:00:20 +02:00
|
|
|
|
|
|
|
# Check for bash
|
|
|
|
[ -z "$BASH_VERSION" ] && return
|
|
|
|
|
|
|
|
####################################################################################################
|
|
|
|
|
|
|
|
__gsettings() {
|
2011-12-17 20:08:50 +01:00
|
|
|
local choices coffset schemadir
|
2010-10-03 08:40:48 +02:00
|
|
|
|
2011-12-17 20:08:50 +01:00
|
|
|
if [ ${COMP_CWORD} -gt 2 ]; then
|
|
|
|
if [ ${COMP_WORDS[1]} = --schemadir ]; then
|
|
|
|
# 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
|
|
|
|
|
|
|
|
case "$((${COMP_CWORD}-$coffset))" in
|
2010-10-03 08:40:48 +02:00
|
|
|
1)
|
2011-12-17 20:08:50 +01:00
|
|
|
choices=$'--schemadir\nhelp \nlist-schemas\nlist-relocatable-schemas\nlist-keys \nlist-children \nlist-recursively \nget \nrange \nset \nreset \nwritable \nmonitor'
|
2010-10-03 08:40:48 +02:00
|
|
|
;;
|
|
|
|
|
|
|
|
2)
|
2011-12-17 20:08:50 +01:00
|
|
|
case "${COMP_WORDS[$(($coffset+1))]}" in
|
|
|
|
--schemadir)
|
|
|
|
COMPREPLY=($(compgen -o dirnames -- ${COMP_WORDS[${COMP_CWORD}]}))
|
|
|
|
return 0
|
|
|
|
;;
|
|
|
|
|
2010-10-03 08:40:48 +02:00
|
|
|
help)
|
2010-10-30 06:00:06 +02:00
|
|
|
choices=$'list-schemas\nlist-relocatable-schemas\nlist-keys\nlist-children\nlist-recursively\nget\nrange\nset\nreset\nwritable\nmonitor'
|
2010-10-03 08:40:48 +02:00
|
|
|
;;
|
2010-10-30 06:00:06 +02:00
|
|
|
list-keys|list-children|list-recursively)
|
2011-12-17 20:08:50 +01:00
|
|
|
choices="$(gsettings $schemadir list-schemas)"$'\n'"$(gsettings $schemadir list-relocatable-schemas | sed -e 's.$.:/.')"
|
2010-10-03 08:40:48 +02:00
|
|
|
;;
|
|
|
|
|
2010-10-04 09:41:03 +02:00
|
|
|
get|range|set|reset|writable|monitor)
|
2011-12-17 20:08:50 +01:00
|
|
|
choices="$(gsettings $schemadir list-schemas | sed -e 's.$. .')"$'\n'"$(gsettings $schemadir list-relocatable-schemas | sed -e 's.$.:/.')"
|
2010-10-03 08:40:48 +02:00
|
|
|
;;
|
|
|
|
esac
|
|
|
|
;;
|
|
|
|
|
|
|
|
3)
|
2011-12-17 20:08:50 +01:00
|
|
|
case "${COMP_WORDS[$(($coffset+1))]}" in
|
2010-10-03 08:40:48 +02:00
|
|
|
set)
|
2011-12-17 20:08:50 +01:00
|
|
|
choices="$(gsettings $schemadir list-keys ${COMP_WORDS[$(($coffset+2))]} 2> /dev/null | sed -e 's.$. .')"
|
2010-10-03 08:40:48 +02:00
|
|
|
;;
|
|
|
|
|
2010-10-04 09:41:03 +02:00
|
|
|
get|range|reset|writable|monitor)
|
2011-12-17 20:08:50 +01: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)
|
2011-12-17 20:08:50 +01:00
|
|
|
case "${COMP_WORDS[$(($coffset+2))]}" in
|
2010-10-30 07:13:42 +02:00
|
|
|
set)
|
2011-12-17 20:08:50 +01: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)
|
|
|
|
unset range[0]
|
|
|
|
;;
|
|
|
|
*)
|
|
|
|
unset range
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
local IFS=$'\n'
|
|
|
|
choices="${range[*]}"
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
;;
|
2010-10-03 08:40:48 +02:00
|
|
|
esac
|
|
|
|
|
|
|
|
local IFS=$'\n'
|
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
|