xinput: improve completion of xinput_devices (with descs)
This commit is contained in:
parent
9f3a538414
commit
460fdafd78
100
src/_xinput
100
src/_xinput
|
@ -93,8 +93,11 @@ _xinput(){
|
||||||
--set-prop
|
--set-prop
|
||||||
)
|
)
|
||||||
|
|
||||||
local context state line expl
|
local context state line
|
||||||
local -A opt_args
|
local -A opt_args
|
||||||
|
# Used with "-O expl" for unsorted.
|
||||||
|
local -a expl
|
||||||
|
expl=(-Vx)
|
||||||
|
|
||||||
_arguments '*:: :->subcmds' && return 0
|
_arguments '*:: :->subcmds' && return 0
|
||||||
|
|
||||||
|
@ -103,94 +106,101 @@ _xinput(){
|
||||||
return
|
return
|
||||||
fi
|
fi
|
||||||
|
|
||||||
typeset -a xinput_devices_id xinput_devices
|
typeset -a xinput_devices_id xinput_devices xinput_devices_name
|
||||||
typeset -A xinput_devices_name
|
local i name
|
||||||
xinput_devices_id=($(xinput list --id-only))
|
for i in ${(on)$(xinput list --id-only)}; do
|
||||||
for i in $(xinput list --id-only)
|
# Removing prefixes, e.g. from "∼ 7" (floating slave).
|
||||||
do
|
i=${i##[^[:digit:]]#}
|
||||||
xinput_devices_name[$i]="$(xinput list --name-only $i)"
|
[[ -n "$i" ]] || continue
|
||||||
done
|
xinput_devices_id+=($i)
|
||||||
xinput_devices=( $xinput_devices_id $xinput_devices_name )
|
name="$(xinput list --name-only $i)"
|
||||||
|
xinput_devices_name+=($name)
|
||||||
|
xinput_devices+=($i\:$name)
|
||||||
|
done
|
||||||
|
xinput_devices+=($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 -O expl \
|
||||||
':list option:($xinput_devices)'
|
':list option:(($xinput_devices))'
|
||||||
;;
|
;;
|
||||||
--list|list)
|
--list|list)
|
||||||
_arguments \
|
_arguments -O expl \
|
||||||
':list option:($xinput_devices --short --long --name-only --id-only)' \
|
'--short' \
|
||||||
':list option:(--short --long --name-only --id-only)'
|
'--long' \
|
||||||
|
'--name-only' \
|
||||||
|
'--id-only' \
|
||||||
|
':list option:(($xinput_devices))' \
|
||||||
;;
|
;;
|
||||||
--set-integer-feedback|set-integer-feedback)
|
--set-integer-feedback|set-integer-feedback)
|
||||||
_arguments \
|
_arguments -O expl \
|
||||||
':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 -O expl \
|
||||||
':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 -O expl \
|
||||||
':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 -O expl \
|
||||||
':list option:($xinput_devices)' \
|
':list option:(($xinput_devices))' \
|
||||||
':list option:(ABSOLUTE RELATIVE)'
|
':list option:(ABSOLUTE RELATIVE)'
|
||||||
;;
|
;;
|
||||||
--test|test)
|
--test|test)
|
||||||
_arguments \
|
_arguments -O expl \
|
||||||
':list option:(-proximity $xinput_devices )' \
|
':list option:(-proximity ($xinput_devices ))' \
|
||||||
':list option:($xinput_devices)'
|
':list option:(($xinput_devices))'
|
||||||
;;
|
;;
|
||||||
--reattach|reattach)
|
--reattach|reattach)
|
||||||
_arguments \
|
_arguments -O expl \
|
||||||
':list option:($xinput_devices)' \
|
':list option:(($xinput_devices))' \
|
||||||
':list option:(master slave)'
|
':list option:(master slave)'
|
||||||
;;
|
;;
|
||||||
--float|float)
|
--float|float)
|
||||||
_arguments \
|
_arguments -O expl \
|
||||||
':list option:($xinput_devices_id)'
|
':list option:(($xinput_devices))'
|
||||||
;;
|
;;
|
||||||
--test-xi2|test-xi2)
|
--test-xi2|test-xi2)
|
||||||
_arguments \
|
_arguments -O expl \
|
||||||
':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 -O expl \
|
||||||
':list option:($xinput_devices)' #property
|
':list option:(($xinput_devices))' #property
|
||||||
;;
|
;;
|
||||||
--create-master|create-master)
|
--create-master|create-master)
|
||||||
_arguments \
|
_arguments -O expl \
|
||||||
':list option:($xinput_devices_id)' # [sendCore (dflt:1)] [enable (dflt:1)]
|
':list option:(($xinput_devices))' # [sendCore (dflt:1)] [enable (dflt:1)]
|
||||||
;;
|
;;
|
||||||
--remove-master|remove-master)
|
--remove-master|remove-master)
|
||||||
_arguments \
|
_arguments -O expl \
|
||||||
':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 -O expl \
|
||||||
':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 -O expl \
|
||||||
':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 -O expl \
|
||||||
':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 -O expl \
|
||||||
':list option:($xinput_devices)' # property val [val ...]
|
':list option:(($xinput_devices))' # property val [val ...]
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue