completions/zsh: add input commands

This commit is contained in:
novakane 2021-06-14 12:26:59 +02:00 committed by Isaac Freund
parent f3024d9198
commit db35f700a8

View File

@ -1,18 +1,12 @@
#compdef riverctl #compdef riverctl
#
# Completion script for riverctl, part of river <https://github.com/ifreund/river>
_riverctl_subcommands()
{
local -a riverctl_subcommands
_riverctl() { riverctl_subcommands=(
_next_prev() { _alternative 'arguments:args:(next previous)' }
_orientations() { _alternative 'arguments:args:(up down left right)' }
_hor_ver() { _alternative 'arguments:args:(horizontal vertical)' }
_attach() { _alternative 'arguments:args:(top bottom)' }
_focus_cursor() { _alternative 'arguments:args:(disabled normal strict)' }
_river_opts() { _alternative 'arguments:args:(-output -focused-output)' }
local -a _cmds
_cmds=(
# Actions # Actions
'close:Close the focused view' 'close:Close the focused view'
'csd-filter-add:Add app-id to the CSD filter list' 'csd-filter-add:Add app-id to the CSD filter list'
@ -56,35 +50,98 @@ _riverctl() {
'opacity:Configure server-side opacity of views' 'opacity:Configure server-side opacity of views'
'set-repeat:Set the keyboard repeat rate and repeat delay' 'set-repeat:Set the keyboard repeat rate and repeat delay'
'xcursor-theme:Set the xcursor theme' 'xcursor-theme:Set the xcursor theme'
# Input
'input:Configure input devices'
'list-inputs:List all input devices'
'list-input-configs:List all input configurations'
) )
local -A opt_args _describe -t command 'command' riverctl_subcommands
}
_arguments -C '*:: :->_cmds' _riverctl_input_subcommands()
{
local -a input_subcommands
if (( CURRENT == 1 )); then input_subcommands=(
_describe -t commands "commands" _cmds 'events:Configure whether the input devices events will be used by river'
return 'accel-profile:Set the pointer acceleration profile'
fi 'pointer-accel:Set the pointer acceleration factor'
'click-method:Set the click method'
'drag:Enable or disable the tap-and-drag functionality'
'drag-lock:Enable or disable the drag lock functionality'
'disable-while-typing:Enable or disable the disable-while-typing functionality'
'middle-emulation:Enable or disable the middle click emulation functionality'
'natural-scroll:Enable or disable the natural scroll functionality'
'left-handed:Enable or disable the left handed mode'
'tap:Enable or disable the tap functionality'
'tap-button-map:Configure the button mapping for tapping'
'scroll-method:Set the scroll method'
'scroll-button:Set the scroll button'
)
_describe -t command 'command' input_subcommands
}
_riverctl_input()
{
local state
_arguments \
'1: :->commands' \
'*:: :->args'
case $state in
commands) _alternative 'common-commands:common:_riverctl_input_subcommands' ;;
args)
case "$words[1]" in case "$words[1]" in
focus-output) _next_prev ;; events) _alternative 'input-cmds:args:(enabled disabled disabled-on-external-mouse)' ;;
focus-view) _next_prev ;; accel-profile) _alternative 'input-cmds:args:(none flat adaptive)' ;;
move) _orientations ;; click-method) _alternative 'input-cmds:args:(none button-area clickfinger)' ;;
resize) _hor_ver ;; drag) _alternative 'input-cmds:args:(enabled disabled)' ;;
snap) _orientations ;; drag-lock) _alternative 'input-cmds:args:(enabled disabled)' ;;
send-to-output) _next_prev ;; disable-while-typing) _alternative 'input-cmds:args:(enabled disabled)' ;;
swap) _next_prev ;; middle-emulation) _alternative 'input-cmds:args:(enabled disabled)' ;;
map) _alternative 'arguments:optional:(-release)' ;; natural-scroll) _alternative 'input-cmds:args:(enabled disabled)' ;;
unmap) _alternative 'arguments:optional:(-release)' ;; left-handed) _alternative 'input-cmds:args:(enabled disabled)' ;;
attach-mode) _attach ;; tap) _alternative 'input-cmds:args:(enabled disabled)' ;;
focus-follows-cursor) _focus_cursor ;; tap-button-map) _alternative 'input-cmds:args:(left-right-middle left-middle-right)' ;;
get-option) _river_opts ;; scroll-method) _alternative 'input-cmds:args:(none two-finger edge button)' ;;
set-option) _river_opts ;;
unset-option) _river_opts ;;
mod-option) _river_opts ;;
*) return 0 ;; *) return 0 ;;
esac esac
;;
return 1 esac
} }
_riverctl()
{
local state
_arguments \
'1: :->commands' \
'*:: :->args'
case $state in
commands) _alternative 'common-commands:common:_riverctl_subcommands' ;;
args)
case "$words[1]" in
focus-output) _alternative 'arguments:args:(next previous)' ;;
focus-view) _alternative 'arguments:args:(next previous)' ;;
input) _riverctl_input ;;
move) _alternative 'arguments:args:(up down left right)' ;;
resize) _alternative 'arguments:args:(horizontal vertical)' ;;
snap) _alternative 'arguments:args:(up down left right)' ;;
send-to-output) _alternative 'arguments:args:(next previous)' ;;
swap) _alternative 'arguments:args:(next previous)' ;;
map) _alternative 'arguments:optional:(-release)' ;;
unmap) _alternative 'arguments:optional:(-release)' ;;
attach-mode) _alternative 'arguments:args:(top bottom)' ;;
focus-follows-cursor) _alternative 'arguments:args:(disabled normal strict)' ;;
*) return 0 ;;
esac
;;
esac
}
_riverctl "$@"