xinput: do not leak variables

This commit is contained in:
Daniel Hahler 2016-02-02 23:18:51 +01:00
parent c2dde89fb3
commit 9f3a538414
1 changed files with 25 additions and 23 deletions

View File

@ -103,92 +103,94 @@ _xinput(){
return return
fi fi
_xinput_devices_id=($(xinput list --id-only)) typeset -a xinput_devices_id xinput_devices
typeset -A xinput_devices_name
xinput_devices_id=($(xinput list --id-only))
for i in $(xinput list --id-only) for i in $(xinput list --id-only)
do do
_xinput_devices_name[$i]="$(xinput list --name-only $i)" xinput_devices_name[$i]="$(xinput list --name-only $i)"
done done
_xinput_devices=( $_xinput_devices_id $_xinput_devices_name ) xinput_devices=( $xinput_devices_id $xinput_devices_name )
# xinput arguments handler # xinput arguments handler
case "$words[1]" in case "$words[1]" in
--get-feedbacks|--set-ptr-feedback|--get-button-map|--query-state|--list-props|--watch-props|get-feedbacks|set-ptr-feedback|get-button-map|query-state|list-props|watch-props|--enable|enable|--map-to-output|map-to-output|--disable|disable) --get-feedbacks|--set-ptr-feedback|--get-button-map|--query-state|--list-props|--watch-props|get-feedbacks|set-ptr-feedback|get-button-map|query-state|list-props|watch-props|--enable|enable|--map-to-output|map-to-output|--disable|disable)
_arguments \ _arguments \
':list option:($_xinput_devices)' ':list option:($xinput_devices)'
;; ;;
--list|list) --list|list)
_arguments \ _arguments \
':list option:($_xinput_devices --short --long --name-only --id-only)' \ ':list option:($xinput_devices --short --long --name-only --id-only)' \
':list option:(--short --long --name-only --id-only)' ':list option:(--short --long --name-only --id-only)'
;; ;;
--set-integer-feedback|set-integer-feedback) --set-integer-feedback|set-integer-feedback)
_arguments \ _arguments \
':list option:($_xinput_devices)' \ ':list option:($xinput_devices)' \
':list option:( feedback )' \ ':list option:( feedback )' \
':list option:( $_xinput_devices_id )' ':list option:( $xinput_devices_id )'
;; ;;
--set-button-map|set-button-map) --set-button-map|set-button-map)
_arguments \ _arguments \
':list option:($_xinput_devices)' #map button 1 [map button 2 [...]] ':list option:($xinput_devices)' #map button 1 [map button 2 [...]]
;; ;;
--set-pointer|set-pointer) --set-pointer|set-pointer)
_arguments \ _arguments \
':list option:($_xinput_devices)' # [x index y index] ':list option:($xinput_devices)' # [x index y index]
;; ;;
--set-mode|set-mode) --set-mode|set-mode)
_arguments \ _arguments \
':list option:($_xinput_devices)' \ ':list option:($xinput_devices)' \
':list option:(ABSOLUTE RELATIVE)' ':list option:(ABSOLUTE RELATIVE)'
;; ;;
--test|test) --test|test)
_arguments \ _arguments \
':list option:(-proximity $_xinput_devices )' \ ':list option:(-proximity $xinput_devices )' \
':list option:($_xinput_devices)' ':list option:($xinput_devices)'
;; ;;
--reattach|reattach) --reattach|reattach)
_arguments \ _arguments \
':list option:($_xinput_devices)' \ ':list option:($xinput_devices)' \
':list option:(master slave)' ':list option:(master slave)'
;; ;;
--float|float) --float|float)
_arguments \ _arguments \
':list option:($_xinput_devices_id)' ':list option:($xinput_devices_id)'
;; ;;
--test-xi2|test-xi2) --test-xi2|test-xi2)
_arguments \ _arguments \
':list option:($_xinput_devices --root)' \ ':list option:($xinput_devices --root)' \
':list option:($_xinput_devices)' ':list option:($xinput_devices)'
;; ;;
--delete-prop|delete-prop) --delete-prop|delete-prop)
_arguments \ _arguments \
':list option:($_xinput_devices)' #property ':list option:($xinput_devices)' #property
;; ;;
--create-master|create-master) --create-master|create-master)
_arguments \ _arguments \
':list option:($_xinput_devices_id)' # [sendCore (dflt:1)] [enable (dflt:1)] ':list option:($xinput_devices_id)' # [sendCore (dflt:1)] [enable (dflt:1)]
;; ;;
--remove-master|remove-master) --remove-master|remove-master)
_arguments \ _arguments \
':list option:($_xinput_devices_id)' # [Floating|AttachToMaster (dflt:Floating)] [returnPointer] [returnKeyboard] ':list option:($xinput_devices_id)' # [Floating|AttachToMaster (dflt:Floating)] [returnPointer] [returnKeyboard]
;; ;;
# --set-cp|set-cp); window device;; # --set-cp|set-cp); window device;;
--set-prop|set-prop) --set-prop|set-prop)
_arguments \ _arguments \
':list option:($_xinput_devices)' \ ':list option:($xinput_devices)' \
':list option:(--type={atom,float,int} --format={8,16,32})' \ ':list option:(--type={atom,float,int} --format={8,16,32})' \
':list option:(--type={atom,float,int} --format={8,16,32})' # property val [val ...] ':list option:(--type={atom,float,int} --format={8,16,32})' # property val [val ...]
;; ;;
--set-int-prop|set-int-prop) --set-int-prop|set-int-prop)
_arguments \ _arguments \
':list option:($_xinput_devices)' # property format (8, 16, 32) val [val ...] ':list option:($xinput_devices)' # property format (8, 16, 32) val [val ...]
;; ;;
--set-float-prop|set-float-prop) --set-float-prop|set-float-prop)
_arguments \ _arguments \
':list option:($_xinput_devices)' # property val [val ...] ':list option:($xinput_devices)' # property val [val ...]
;; ;;
--set-atom-prop|set-atom-prop) --set-atom-prop|set-atom-prop)
_arguments \ _arguments \
':list option:($_xinput_devices)' # property val [val ...] ':list option:($xinput_devices)' # property val [val ...]
;; ;;
esac esac
} }