river: add rules system

This is a breaking change and replaces the previous
csd-filter-add/remove and float-filter-add/remove commands.

See the riverctl(1) man page for documentation on the new system.
This commit is contained in:
Isaac Freund
2023-03-12 15:40:42 +01:00
parent 05eac54b07
commit b2b2c9ed13
17 changed files with 662 additions and 271 deletions

View File

@ -8,9 +8,7 @@ function __riverctl_completion ()
keyboard-group-add \
keyboard-group-remove \
keyboard-layout \
csd-filter-add \
exit \
float-filter-add \
focus-output \
focus-view \
input \
@ -18,6 +16,9 @@ function __riverctl_completion ()
list-input-configs \
move \
resize \
rule-add \
rule-del \
list-rules \
snap \
send-to-output \
spawn \
@ -61,6 +62,8 @@ function __riverctl_completion ()
"focus-output"|"focus-view"|"send-to-output"|"swap") OPTS="next previous" ;;
"move"|"snap") OPTS="up down left right" ;;
"resize") OPTS="horizontal vertical" ;;
"rule-add"|"rule-del") OPTS="float no-float ssd csd" ;;
"list-rules") OPTS="float ssd" ;;
"map") OPTS="-release -repeat -layout" ;;
"unmap") OPTS="-release" ;;
"attach-mode") OPTS="top bottom" ;;

View File

@ -12,9 +12,7 @@ end
# Actions
complete -c riverctl -x -n '__fish_riverctl_complete_arg 1' -a 'close' -d 'Close the focued view'
complete -c riverctl -x -n '__fish_riverctl_complete_arg 1' -a 'csd-filter-add' -d 'Add app-id to the CSD filter list'
complete -c riverctl -x -n '__fish_riverctl_complete_arg 1' -a 'exit' -d 'Exit the compositor, terminating the Wayland session'
complete -c riverctl -x -n '__fish_riverctl_complete_arg 1' -a 'float-filter-add' -d 'Add app-id to the float filter list'
complete -c riverctl -x -n '__fish_riverctl_complete_arg 1' -a 'focus-output' -d 'Focus the next or previous output'
complete -c riverctl -x -n '__fish_riverctl_complete_arg 1' -a 'focus-view' -d 'Focus the next or previous view in the stack'
complete -c riverctl -x -n '__fish_riverctl_complete_arg 1' -a 'input' -d 'Create a configuration rule for an input device'
@ -49,6 +47,10 @@ complete -c riverctl -x -n '__fish_riverctl_complete_arg 1' -a 'map-switch '
complete -c riverctl -x -n '__fish_riverctl_complete_arg 1' -a 'unmap' -d 'Remove the mapping defined by the arguments'
complete -c riverctl -x -n '__fish_riverctl_complete_arg 1' -a 'unmap-pointer' -d 'Remove the pointer mapping defined by the arguments'
complete -c riverctl -x -n '__fish_riverctl_complete_arg 1' -a 'unmap-switch' -d 'Remove the switch mapping defined by the arguments'
# Rules
complete -c riverctl -x -n '__fish_riverctl_complete_arg 1' -a 'rule-add' -d 'Apply an action to matching views'
complete -c riverctl -x -n '__fish_riverctl_complete_arg 1' -a 'rule-del' -d 'Delete a rule added with rule-add'
complete -c riverctl -x -n '__fish_riverctl_complete_arg 1' -a 'list-rules' -d 'Print rules in a given list'
# Configuration
complete -c riverctl -x -n '__fish_riverctl_complete_arg 1' -a 'attach-mode' -d 'Configure where new views should attach to the view stack'
complete -c riverctl -x -n '__fish_riverctl_complete_arg 1' -a 'background-color' -d 'Set the background color'
@ -81,6 +83,9 @@ complete -c riverctl -x -n '__fish_seen_subcommand_from unmap' -a
complete -c riverctl -x -n '__fish_seen_subcommand_from attach-mode' -a 'top bottom'
complete -c riverctl -x -n '__fish_seen_subcommand_from focus-follows-cursor' -a 'disabled normal always'
complete -c riverctl -x -n '__fish_seen_subcommand_from set-cursor-warp' -a 'disabled on-output-change on-focus-change'
complete -c riverctl -x -n '__fish_seen_subcommand_from rule-add' -a 'float no-float ssd csd'
complete -c riverctl -x -n '__fish_seen_subcommand_from rule-del' -a 'float no-float ssd csd'
complete -c riverctl -x -n '__fish_seen_subcommand_from list-rules' -a 'float ssd'
# Subcommands for 'input'
complete -c riverctl -x -n '__fish_seen_subcommand_from input; and __fish_riverctl_complete_arg 2' -a "(__riverctl_list_input_devices)"

View File

@ -9,9 +9,7 @@ _riverctl_subcommands()
riverctl_subcommands=(
# 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'
@ -43,6 +41,10 @@ _riverctl_subcommands()
'unmap:Remove the mapping defined by the arguments'
'unmap-pointer:Remove the pointer mapping defined by the arguments'
'unmap-switch:Remove the switch mapping defined by the arguments'
# Rules
'rule-add:Apply an action to matching views'
'rule-del:Delete a rule added with rule-add'
'list-rules:Print rules in a given list'
# Configuration
'attach-mode:Configure where new views should attach to the view stack'
'background-color:Set the background color'
@ -181,6 +183,9 @@ _riverctl()
focus-follows-cursor) _alternative 'arguments:args:(disabled normal always)' ;;
set-cursor-warp) _alternative 'arguments:args:(disabled on-output-change on-focus-change)' ;;
hide-cursor) _riverctl_hide_cursor ;;
rule-add) _alternative 'arguments:args:(float no-float ssd csd)' ;;
rule-del) _alternative 'arguments:args:(float no-float ssd csd)' ;;
list-rules) _alternative 'arguments:args:(float ssd)' ;;
*) return 0 ;;
esac
;;