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
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
14 _enlightenment_remote() {
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"
29 COMPREPLY=($(compgen -W "${opts/-h -help --help}" -- "${cur}"))
32 -always-click-to-focus-set| \
33 -always-click-to-raise-set| \
34 -border-shade-animate-set| \
36 -focus-last-focused-per-desktop-set| \
37 -focus-revert-on-hide-or-close-set| \
38 -kill-if-close-not-possible-set| \
41 -move-info-follows-set| \
44 -resize-info-follows-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}"))
55 if [[ ${COMP_CWORD} -eq 2 ]]; then
56 COMPREPLY=($(compgen -W "${BINDING_CONTEXT}" -- "${cur}"))
57 elif [[ ${COMP_CWORD} -eq 3 ]]; then
59 elif [[ ${COMP_CWORD} -eq 4 ]]; then
60 # Find the selected modifiers
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}"
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
86 context=${COMP_WORDS[2]}
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]}
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}"))
118 -border-shade-transition-set)
119 COMPREPLY=($(compgen -W " 0 1 2 3" -- "${cur}"))
123 # TODO Add filename expansion, and only match dirs and .edj files
127 engines=$(enlightenment_remote -engine-list|grep REPLY:|awk '{print $2}')
128 COMPREPLY=($(compgen -W "${engines}" -- "${cur}"))
131 -default-profile-set)
132 profiles=$(enlightenment_remote -profile-list|grep REPLY:|awk '{print $2}')
133 COMPREPLY=($(compgen -W "${profiles}" -- "${cur}"))
137 COMPREPLY=($(compgen -W "${DIRS}" -- "${cur}"))
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
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}"))
160 displays=$(/bin/ls $HOME/.ecore/enlightenment-\(*\)/0|sed -e 's+.*enlightenment-(\(.*\))/.*+\1+')
161 COMPREPLY=($(compgen -W "${displays}" -- "${cur}"))
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}"))
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
183 COMPREPLY=($(compgen -W "CLICK MOUSE SLOPPY" -- "${cur}"))
187 COMPREPLY=($(compgen -W "NONE NEW_WINDOW NEW_DIALOG NEW_DIALOG_IF_OWNER_FOCUSED" -- "${cur}"))
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}"))
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
207 -font-fallback-remove)
208 fonts=$(enlightenment_remote -font-fallback-list|grep REPLY:|awk '{print $2}')
209 COMPREPLY=($(compgen -W "${fonts}" -- "${cur}"))
212 -fullscreen-policy-set)
213 COMPREPLY=($(compgen -W "RESIZE ZOOM" -- "${cur}"))
217 languages=$(enlightenment_remote -lang-list|grep REPLY:|awk '{print $2}')
218 COMPREPLY=($(compgen -W "${languages}" -- "${cur}"))
221 -maximize-policy-set)
222 COMPREPLY=($(compgen -W "FULLSCREEN SMART EXPAND FILL" -- "${cur}"))
226 modules=$(enlightenment_remote -module-list|grep REPLY:|grep 0$|awk '{print $2}')
227 COMPREPLY=($(compgen -W "${modules}" -- "${cur}"))
231 modules=$(enlightenment_remote -module-list|grep REPLY:|grep 1$|awk '{print $2}')
232 COMPREPLY=($(compgen -W "${modules}" -- "${cur}"))
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}"))
244 modules=$(enlightenment_remote -module-list|grep REPLY:|awk '{print $2}')
245 COMPREPLY=($(compgen -W "${modules}" -- "${cur}"))
249 profiles=$(enlightenment_remote -profile-list|grep REPLY:|awk '{print $2}')
250 COMPREPLY=($(compgen -W "${profiles}" -- "${cur}"))
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}"))
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
269 transitions=$(enlightenment_remote -transition-list|grep REPLY:|awk '{print $2}')
270 COMPREPLY=($(compgen -W "${transitions}" -- "${cur}"))
273 -window-placement-policy-set)
274 COMPREPLY=($(compgen -W "SMART CURSOR MANUAL" -- "${cur}"))
279 if [[ "${cur}" == -* ]] || [[ ${COMP_CWORD} -eq 1 ]]; then
280 COMPREPLY=($(compgen -W "${opts}" -- "${cur}"))
283 complete -F _enlightenment_remote enlightenment_remote