Git init
[framework/uifw/e17.git] / data / other / enlightenment_remote
1 # $Id: enlightenment_remote 53943 2010-10-28 00:34:03Z raster $
2 # bash-completion script for enlightenment_remote
3 # By Justin Rocha (Xenith)
4 # Additions by Sebastian Dransfeld
5
6 # TODO:
7 # Add here:
8 # -binding-mouse-add, -binding-mouse-del
9 # -binding-signal-add, -binding-signal-del
10 # -binding-wheel-add, -binding-wheel-del
11 # -desktop-bg-add, -desktop-bg-del
12 # -desktop-name-add, -desktop-name-del
13
14 _enlightenment_remote() {
15         local cur prev opts
16         COMPREPLY=()
17         cur=${COMP_WORDS[COMP_CWORD]}
18         prev=${COMP_WORDS[COMP_CWORD-1]}
19         action=${COMP_WORDS[1]}
20         opts=`enlightenment_remote -h | awk '{print $1}' | grep -v "OPTIONS:" | xargs`
21         BINDING_CONTEXT="NONE BORDER ZONE CONTAINER MANAGER MENU WINLIST POPUP ANY"
22         ENGINE_CONTEXT="INIT CONTAINER ZONE BORDER MENU ERROR WIN POPUP DRAG"
23         MODIFIERS="NONE SHIFT| SHIFT CONTROL| CONTROL ALT| ALT WIN| WIN"
24         DIRS="data images fonts themes init icons modules backgrounds"
25
26
27         case "${action}" in
28         -h|-help|--help)
29                 COMPREPLY=($(compgen -W "${opts/-h -help --help}" -- "${cur}"))
30                 return 0
31                 ;;
32         -always-click-to-focus-set| \
33         -always-click-to-raise-set| \
34         -border-shade-animate-set| \
35         -edge-flip-set| \
36         -focus-last-focused-per-desktop-set| \
37         -focus-revert-on-hide-or-close-set| \
38         -kill-if-close-not-possible-set| \
39         -kill-process-set| \
40         -modal-windows-set| \
41         -move-info-follows-set| \
42         -pass-click-on-set| \
43         -ping-clients-set| \
44         -resize-info-follows-set| \
45         -transient-*-set| \
46         -use-*-set| \
47         -winlist-list-*-set| \
48         -winlist-scroll-animate-set| \
49         -winlist-warp-at-end-set| \
50         -winlist-warp-while-selecting-set)
51                 COMPREPLY=($(compgen -W " 0 1" -- "${cur}"))
52                 return 0
53                 ;;
54         -binding-key-add)
55                 if [[ ${COMP_CWORD} -eq 2 ]]; then
56                         COMPREPLY=($(compgen -W "${BINDING_CONTEXT}" -- "${cur}"))
57                 elif [[ ${COMP_CWORD} -eq 3 ]]; then
58                         COMPREPLY=()
59                 elif [[ ${COMP_CWORD} -eq 4 ]]; then
60                         # Find the selected modifiers
61                         selected=${cur#\'}
62                         selected=$(echo $selected | sed -e 's/\(.*|\)\?.*/\1/')
63                         # create updated modifier list
64                         if [[ "${selected}" ]]; then
65                                 for modifier in ${MODIFIERS}; do
66                                         if ! echo $selected | grep -q $modifier; then
67                                                 curmod="${curmod} ${selected}${modifier}"
68                                         fi
69                                 done
70                         else
71                                 curmod=${MODIFIERS}
72                         fi
73                         
74                         COMPREPLY=($(compgen -P "'" -S "'" -W "${curmod}" -- "${cur}"))
75                 elif [[ ${COMP_CWORD} -eq 5 ]]; then
76                         COMPREPLY=($(compgen -W "0 1" -- "${cur}"))
77                 elif [[ ${COMP_CWORD} -eq 6 ]]; then
78                         actions=$(enlightenment_remote -action-list|grep REPLY:|awk '{print $2}')
79                         COMPREPLY=($(compgen -W "${actions}" -- "${cur}"))
80                 elif [[ ${COMP_CWORD} -eq 7 ]]; then
81                         COMPREPLY=()
82                 fi
83                 return 0
84                 ;;
85         -binding-key-del)
86                 context=${COMP_WORDS[2]}
87                 key=${COMP_WORDS[3]}
88                 modifiers=${COMP_WORDS[4]}
89                 modifiers=${modifiers#\'}
90                 modifiers=${modifiers%\'}
91                 any_mod=${COMP_WORDS[5]}
92                 action=${COMP_WORDS[6]}
93                 params=${COMP_WORDS[7]}
94                 SIFS=$IFS
95                 IFS=$'\n'
96                 if [[ ${COMP_CWORD} -eq 2 ]]; then
97                         binding=$(enlightenment_remote -binding-key-list|grep 'REPLY:'|sed -e "s/.*CONTEXT=\(\S\+\)\s\+KEY=\"\(\S\+\)\"\s\+MODIFIERS=\(\S\+\)\s\+ANY_MOD=\(\S\+\)\s\+ACTION=\"\(\S\+\)\"\s\+PARAMS=\"\(\S\+\)\".*/'\1 \2 \3 \4 \5 \6'/"|grep -v 'REPLY:')
98                         COMPREPLY=($(compgen -W "${binding}" -- "${cur}"))
99                 elif [[ ${COMP_CWORD} -eq 3 ]]; then
100                         binding=$(enlightenment_remote -binding-key-list|grep 'REPLY:'|sed -e "s/.*CONTEXT=${context}\s\+KEY=\"\(\S\+\)\"\s\+MODIFIERS=\(\S\+\)\s\+ANY_MOD=\(\S\+\)\s\+ACTION=\"\(\S\+\)\"\s\+PARAMS=\"\(\S\+\)\".*/'\1 \2 \3 \4 \5'/"|grep -v 'REPLY:')
101                         COMPREPLY=($(compgen -W "${binding}" -- "${cur}"))
102                 elif [[ ${COMP_CWORD} -eq 4 ]]; then
103                         binding=$(enlightenment_remote -binding-key-list|grep 'REPLY:'|sed -e "s/.*CONTEXT=${context}\s\+KEY=\"${key}\"\s\+MODIFIERS=\(\S\+\)\s\+ANY_MOD=\(\S\+\)\s\+ACTION=\"\(\S\+\)\"\s\+PARAMS=\"\(\S\+\)\".*/'\1 \2 \3 \4'/"|grep -v 'REPLY:')
104                         COMPREPLY=($(compgen -W "${binding}" -- "${cur}"))
105                 elif [[ ${COMP_CWORD} -eq 5 ]]; then
106                         binding=$(enlightenment_remote -binding-key-list|grep 'REPLY:'|sed -e "s/.*CONTEXT=${context}\s\+KEY=\"${key}\"\s\+MODIFIERS=${modifiers}\s\+ANY_MOD=\(\S\+\)\s\+ACTION=\"\(\S\+\)\"\s\+PARAMS=\"\(\S\+\)\".*/'\1 \2 \3'/"|grep -v 'REPLY:')
107                         COMPREPLY=($(compgen -W "${binding}" -- "${cur}"))
108                 elif [[ ${COMP_CWORD} -eq 6 ]]; then
109                         binding=$(enlightenment_remote -binding-key-list|grep 'REPLY:'|sed -e "s/.*CONTEXT=${context}\s\+KEY=\"${key}\"\s\+MODIFIERS=${modifiers}\s\+ANY_MOD=${any_mod}\s\+ACTION=\"\(\S\+\)\"\s\+PARAMS=\"\(\S\+\)\".*/'\1 \2'/"|grep -v 'REPLY:')
110                         COMPREPLY=($(compgen -W "${binding}" -- "${cur}"))
111                 elif [[ ${COMP_CWORD} -eq 7 ]]; then
112                         binding=$(enlightenment_remote -binding-key-list|grep 'REPLY:'|sed -e "s/.*CONTEXT=${context}\s\+KEY=\"${key}\"\s\+MODIFIERS=${modifiers}\s\+ANY_MOD=${any_mod}\s\+ACTION=\"${action}\"\s\+PARAMS=\"\(\S\+\)\".*/'\1'/"|grep -v 'REPLY:')
113                         COMPREPLY=($(compgen -W "${binding}" -- "${cur}"))
114                 fi
115                 IFS=$SIFS
116                 return 0
117                 ;;
118         -border-shade-transition-set)
119                 COMPREPLY=($(compgen -W " 0 1 2 3" -- "${cur}"))
120                 return 0
121                 ;;
122         -default-bg-set)
123                 # TODO Add filename expansion, and only match dirs and .edj files
124                 return 0
125                 ;;
126         -default-engine-set)
127                 engines=$(enlightenment_remote -engine-list|grep REPLY:|awk '{print $2}')
128                 COMPREPLY=($(compgen -W "${engines}" -- "${cur}"))
129                 return 0
130                 ;;
131         -default-profile-set)
132                 profiles=$(enlightenment_remote -profile-list|grep REPLY:|awk '{print $2}')
133                 COMPREPLY=($(compgen -W "${profiles}" -- "${cur}"))
134                 return 0
135                 ;;
136         -dirs-list)
137                 COMPREPLY=($(compgen -W "${DIRS}" -- "${cur}"))
138                 return 0
139                 ;;
140         -dirs-list-append|-dirs-list-prepend)
141                 if [[ ${COMP_CWORD} -eq 2 ]]; then
142                         COMPREPLY=($(compgen -W "${DIRS}" -- "${cur}"))
143                 elif [[ ${COMP_CWORD} -eq 3 ]]; then
144                         # TODO Add filename expansion, and only match dirs
145                         COMPREPLY=()
146                 fi
147                 return 0
148                 ;;
149         -dirs-list-remove)
150                 dir=${COMP_WORDS[2]}
151                 if [[ ${COMP_CWORD} -eq 2 ]]; then
152                         COMPREPLY=($(compgen -W "${DIRS}" -- "${cur}"))
153                 elif [[ ${COMP_CWORD} -eq 3 ]]; then
154                         dirs=$(enlightenment_remote -dirs-list ${dir}|grep REPLY:|awk '{print $2}')
155                         COMPREPLY=($(compgen -W "${dirs}" -- "${cur}"))
156                 fi
157                 return 0
158                 ;;
159         -display)
160                 displays=$(/bin/ls $HOME/.ecore/enlightenment-\(*\)/0|sed -e 's+.*enlightenment-(\(.*\))/.*+\1+')
161                 COMPREPLY=($(compgen -W "${displays}" -- "${cur}"))
162                 return 0
163                 ;;
164         -engine-set)
165                 if [[ ${COMP_CWORD} -eq 2 ]]; then
166                         COMPREPLY=($(compgen -W "${ENGINE_CONTEXT}" -- "${cur}"))
167                 elif [[ ${COMP_CWORD} -eq 3 ]]; then
168                         engines=$(enlightenment_remote -engine-list|grep REPLY:|awk '{print $2}')
169                         COMPREPLY=($(compgen -W "DEFAULT ${engines}" -- "${cur}"))
170                 fi
171                 return 0
172                 ;;
173         -exec-action)
174                 if [[ ${COMP_CWORD} -eq 2 ]]; then
175                         actions=$(enlightenment_remote -action-list|grep REPLY:|awk '{print $2}')
176                         COMPREPLY=($(compgen -W "${actions}" -- "${cur}"))
177                 elif [[ ${COMP_CWORD} -eq 3 ]]; then
178                         COMPREPLY=()
179                 fi
180                 return 0
181                 ;;
182         -focus-policy-set)
183                 COMPREPLY=($(compgen -W "CLICK MOUSE SLOPPY" -- "${cur}"))
184                 return 0
185                 ;;
186         -focus-setting-set)
187                 COMPREPLY=($(compgen -W "NONE NEW_WINDOW NEW_DIALOG NEW_DIALOG_IF_OWNER_FOCUSED" -- "${cur}"))
188                 return 0
189                 ;;
190         -font-default-get|-font-default-remove)
191                 classes=$(enlightenment_remote -font-default-list|grep REPLY:|sed -e 's/.*TEXT_CLASS=\"\(\S\+\)\".*/\1/')
192                 COMPREPLY=($(compgen -W "${classes}" -- "${cur}"))
193                 return 0
194                 ;;
195         -font-default-set)
196                 if [[ ${COMP_CWORD} -eq 2 ]]; then
197                         classes=$(enlightenment_remote -font-default-list|grep REPLY:|sed -e 's/.*TEXT_CLASS=\"\(\S\+\)\".*/\1/')
198                         COMPREPLY=($(compgen -W "${classes}" -- "${cur}"))
199                 elif [[ ${COMP_CWORD} -eq 3 ]]; then
200                         fonts=$(enlightenment_remote -font-available-list|grep REPLY:|awk '{print $2}')
201                         COMPREPLY=($(compgen -W "${fonts}" -- "${cur}"))
202                 elif [[ ${COMP_CWORD} -eq 4 ]]; then
203                         COMPREPLY=()
204                 fi
205                 return 0
206                 ;;
207         -font-fallback-remove)
208                 fonts=$(enlightenment_remote -font-fallback-list|grep REPLY:|awk '{print $2}')
209                 COMPREPLY=($(compgen -W "${fonts}" -- "${cur}"))
210                 return 0
211                 ;;
212         -fullscreen-policy-set)
213                 COMPREPLY=($(compgen -W "RESIZE ZOOM" -- "${cur}"))
214                 return 0
215                 ;;
216         -lang-set)
217                 languages=$(enlightenment_remote -lang-list|grep REPLY:|awk '{print $2}')
218                 COMPREPLY=($(compgen -W "${languages}" -- "${cur}"))
219                 return 0
220                 ;;
221         -maximize-policy-set)
222                 COMPREPLY=($(compgen -W "FULLSCREEN SMART EXPAND FILL" -- "${cur}"))
223                 return 0
224                 ;;
225         -module-enable)
226                 modules=$(enlightenment_remote -module-list|grep REPLY:|grep 0$|awk '{print $2}')
227                 COMPREPLY=($(compgen -W "${modules}" -- "${cur}"))
228                 return 0
229                 ;;
230         -module-disable)
231                 modules=$(enlightenment_remote -module-list|grep REPLY:|grep 1$|awk '{print $2}')
232                 COMPREPLY=($(compgen -W "${modules}" -- "${cur}"))
233                 return 0
234                 ;;
235         -module-load)
236                 extra_dir=$(pkg-config --variable=modules enlightenment)
237                 # This is a hack. pkg-config should return extra dir and standard dir
238                 dir=${extra_dir%_extra}
239                 modules=$(cd ${dir} && /bin/ls && cd ${extra_dir} && /bin/ls)
240                 COMPREPLY=($(compgen -W "${modules}" -- "${cur}"))
241                 return 0
242                 ;;
243         -module-unload)
244                 modules=$(enlightenment_remote -module-list|grep REPLY:|awk '{print $2}')
245                 COMPREPLY=($(compgen -W "${modules}" -- "${cur}"))
246                 return 0
247                 ;;
248         -profile-del)
249                 profiles=$(enlightenment_remote -profile-list|grep REPLY:|awk '{print $2}')
250                 COMPREPLY=($(compgen -W "${profiles}" -- "${cur}"))
251                 return 0
252                 ;;
253         -theme-get|-theme-remove)
254                 theme_categories=$(enlightenment_remote -theme-category-list|grep REPLY:|awk '{print $2}')
255                 COMPREPLY=($(compgen -W "${theme_categories}" -- "${cur}"))
256                 return 0
257                 ;;
258         -theme-set)
259                 if [[ ${COMP_CWORD} -eq 2 ]]; then
260                         theme_categories=$(enlightenment_remote -theme-category-list|grep REPLY:|awk '{print $2}')
261                         COMPREPLY=($(compgen -W "${theme_categories}" -- "${cur}"))
262                 elif [[ ${COMP_CWORD} -eq 3 ]]; then
263                         # TODO Add filename expansion, and only match dirs and .edj files
264                         COMPREPLY=()
265                 fi
266                 return 0
267                 ;;
268         -transition-*-set)
269                 transitions=$(enlightenment_remote -transition-list|grep REPLY:|awk '{print $2}')
270                 COMPREPLY=($(compgen -W "${transitions}" -- "${cur}"))
271                 return 0
272                 ;;
273         -window-placement-policy-set)
274                 COMPREPLY=($(compgen -W "SMART CURSOR MANUAL" -- "${cur}"))
275                 return 0
276                 ;;
277         esac
278
279         if [[ "${cur}" == -* ]] || [[ ${COMP_CWORD} -eq 1 ]]; then
280         COMPREPLY=($(compgen -W "${opts}" -- "${cur}"))
281         fi
282 }
283 complete -F _enlightenment_remote enlightenment_remote
284