File indexing completed on 2024-05-05 17:45:46
0001 #compdef systemsettings systemsettings5 kcmshell5 kinfocenter 0002 0003 # SPDX-FileCopyrightText: 2022 ivan tkachenko <me@ratijas.tk> 0004 # 0005 # SPDX-License-Identifier: GPL-2.0-or-later 0006 0007 # standard stuff for `_arguments -C` 0008 local context state state_descr line 0009 typeset -A opt_args 0010 0011 local ret=1 kcm_line kcm_name kcm_desc quantity 0012 local -a lines kcm_list kcmshell5 0013 local -A kcm_assoc 0014 0015 if [[ "$service" == "kcmshell5" ]]; then 0016 kcmshell5=( 0017 '--caption=[Use a specific caption for the window]:caption:' 0018 '--icon=[Use a specific icon for the window]:icon:' 0019 ) 0020 quantity='*' 0021 else 0022 quantity='1' 0023 fi 0024 0025 _arguments -C \ 0026 $kcmshell5 \ 0027 '(- *)--help[Displays help on commandline options.]' \ 0028 '(- *)--list[List all possible modules]' \ 0029 '--args=[Arguments for the module]:arguments:' \ 0030 "$quantity:module:->kcm" \ 0031 && ret=0 0032 0033 case $state in 0034 kcm) 0035 lines=( ${(f)"$(_call_program kcm-list $service --list)"} ) 0036 lines[1]=() # first line is header, drop it 0037 0038 kcm_assoc=() 0039 for kcm_line in $lines ; do 0040 # split at hypen into name and description, and strip whitespace 0041 kcm_name=${kcm_line%% *} 0042 kcm_desc=${kcm_line##*- } 0043 # skip already specified KCMs except for current word 0044 if (( $words[(Ie)$kcm_name] && $words[(Ie)$kcm_name] != $CURRENT )); then 0045 continue 0046 fi 0047 # some kcm names may get duplicates e.g. because of development setup, 0048 # store them in hash to automatically deduplicate 0049 kcm_assoc[$kcm_name]=$kcm_desc 0050 done 0051 0052 kcm_list=() 0053 for kcm_name kcm_desc in ${(@kv)kcm_assoc} ; do # iterate over array (@) of keys (k) and values (v) 0054 kcm_desc=${kcm_desc//:/\\:} # espace double colons for _describe 0055 kcm_list+=( "${kcm_name}:${kcm_desc}" ) 0056 done 0057 0058 _describe -t kcm 'settings module' kcm_list && ret=0 0059 ;; 0060 esac 0061 0062 return $ret