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