river/completions/zsh/_riverctl
Isaac Freund 871fc7c8de river-options: remove protocol
This protocol involves far too much accidental complexity. The original
motivating use-case was to provide a convenient way to send arbitrary
data to layout clients at runtime in order to avoid layout clients
needing to implement their own IPC and do this over a side-channel.
Instead of implementing a quite complex but still rigid options protocol
and storing this state in the compositor, instead we will simply add
events to the layout protocol to support this use case.

Consider the status quo event sequence:

1. send get_option_handle request (riverctl)
2. roundtrip waiting for first event (riverctl)
3. send set_foo_value request (riverctl)
4. receive set_foo_value request (river)
5. send foo_value event to all current handles (river)
6. receive foo_value event (rivertile)
7. send parameters_changed request (rivertile)
8. receive parameters_changed request (river)
9. send layout_demand (river)

And compare with the event sequence after the proposed change:

1. send set_foo_value request (riverctl)
2. receive set_foo_value request (river)
3. send set_foo_value event (river)
4. send layout_demand (river)

This requires *much* less back and forth between the server and clients
and is clearly much simpler.
2021-04-27 00:10:20 +02:00

89 lines
3.7 KiB
Plaintext

#compdef riverctl
_riverctl() {
_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
'close:Close the focused view'
'csd-filter-add:Add app-id to the CSD filter list'
'exit:Exit the compositor, terminating the Wayland session'
'float-filter-add:Add app-id to the float filter list'
'focus-output:Focus the next or previous output'
'focus-view:Focus the next or previous view in the stack'
'move:Move the focused view in the specified direction'
'resize:Resize the focused view along the given axis'
'snap:Snap the focused view to the specified screen edge'
'send-to-output:Send the focused view to the next or the previous output'
'spawn:Run shell_command using /bin/sh -c'
'swap:Swap the focused view with the next/previous visible non-floating view'
'toggle-float:Toggle the floating state of the focused view'
'toggle-fullscreen:Toggle the fullscreen state of the focused view'
'zoom:Bump the focused view to the top of the layout stack'
'default-layout:Set the layout namespace to be used by all outputs by default.'
'output-layout:Set the layout namespace of currently focused output.'
# Tag management
'set-focused-tags:Show views with tags corresponding to the set bits of tags'
'set-view-tags:Assign the currently focused view the tags corresponding to the set bits of tags'
'toggle-focused-tags:Toggle visibility of views with tags corresponding to the set bits of tags'
'toggle-view-tags:Toggle the tags of the currently focused view'
'spawn-tagmask:Set a tagmask to filter the tags assigned to newly spawned views on the focused output'
# Mappings
'declare-mode:Create a new mode'
'enter-mode:Switch to given mode if it exists'
'map:Run command when key is pressed while modifiers are held down and in the specified mode'
'map-pointer:Move or resize views when button and modifiers are held down while in the specified mode'
'unmap:Remove the mapping defined by the arguments'
'unmap-pointer:Remove the pointer mapping defined by the arguments'
# Configuration
'attach-mode:Configure where new views should attach to the view stack for the currently focused output'
'background-color:Set the background color'
'border-color-focused:Set the border color of focused views'
'border-color-unfocused:Set the border color of unfocused views'
'border-width:Set the border width to pixels'
'focus-follows-cursor:Configure the focus behavior when moving cursor'
'opacity:Configure server-side opacity of views'
'set-repeat:Set the keyboard repeat rate and repeat delay'
'xcursor-theme:Set the xcursor theme'
)
local -A opt_args
_arguments -C '*:: :->_cmds'
if (( CURRENT == 1 )); then
_describe -t commands "commands" _cmds
return
fi
case "$words[1]" in
focus-output) _next_prev ;;
focus-view) _next_prev ;;
move) _orientations ;;
resize) _hor_ver ;;
snap) _orientations ;;
send-to-output) _next_prev ;;
swap) _next_prev ;;
map) _alternative 'arguments:optional:(-release)' ;;
unmap) _alternative 'arguments:optional:(-release)' ;;
attach-mode) _attach ;;
focus-follows-cursor) _focus_cursor ;;
get-option) _river_opts ;;
set-option) _river_opts ;;
unset-option) _river_opts ;;
mod-option) _river_opts ;;
*) return 0 ;;
esac
return 1
}