river-options: rework, bump to v2

Options are now all global but may be overridden per-output. If an
output local value is requested but none has been set, the global value
is provided instead. This makes for much better ergonomics when
configuring layout related options in particular.
This commit is contained in:
Isaac Freund
2021-04-15 00:28:39 +02:00
parent 33fb7725c5
commit d08032d685
19 changed files with 919 additions and 734 deletions

View File

@ -45,6 +45,7 @@ function __riverctl_completion ()
declare-option \
get-option \
set-option \
unset-option \
mod-option"
COMPREPLY=($(compgen -W "${OPTS}" -- "${COMP_WORDS[1]}"))
elif [ "${COMP_CWORD}" -eq 2 ]
@ -56,7 +57,7 @@ function __riverctl_completion ()
"map"|"unmap") OPTS="-release" ;;
"attach-mode") OPTS="top bottom" ;;
"focus-follows-cursor") OPTS="disabled normal strict" ;;
"declare-option"|"get-option"|"set-option"|"mod-option") OPTS="-output -focused-output" ;;
"get-option"|"set-option"|"unset-option"|"mod-option") OPTS="-output -focused-output" ;;
*) return ;;
esac
COMPREPLY=($(compgen -W "${OPTS}" -- "${COMP_WORDS[2]}"))
@ -66,4 +67,3 @@ function __riverctl_completion ()
}
complete -F __riverctl_completion riverctl

View File

@ -1,6 +1,6 @@
function __fish_riverctl_complete_no_subcommand
for i in (commandline -opc)
if contains -- $i close csd-filter-add exit float-filter-add focus-output focus-view layout mod-main-count mod-main-factor move resize snap send-to-output spawn swap toggle-float toggle-fullscreen zoom set-focused-tags set-view-tags toggle-focused-tags toggle-view-tags spawn-tagmask declare-mode enter-mode map map-pointer unmap unmap-pointer attach-mode background-color border-color-focused border-color-unfocused border-width focus-follows-cursor opacity outer-padding set-repeat view-padding xcursor-theme declare-option get-option set-option mod-option output_title
if contains -- $i close csd-filter-add exit float-filter-add focus-output focus-view layout mod-main-count mod-main-factor move resize snap send-to-output spawn swap toggle-float toggle-fullscreen zoom set-focused-tags set-view-tags toggle-focused-tags toggle-view-tags spawn-tagmask declare-mode enter-mode map map-pointer unmap unmap-pointer attach-mode background-color border-color-focused border-color-unfocused border-width focus-follows-cursor opacity outer-padding set-repeat view-padding xcursor-theme declare-option get-option set-option unset-option mod-option output_title
return 1
end
end
@ -55,6 +55,7 @@ complete -c riverctl -x -n '__fish_riverctl_complete_no_subcommand' -a xcursor-t
complete -c riverctl -x -n '__fish_riverctl_complete_no_subcommand' -a declare-option -d 'Declare a new option with the given type and initial value'
complete -c riverctl -x -n '__fish_riverctl_complete_no_subcommand' -a get-option -d 'Print the current value of the given option to stdout'
complete -c riverctl -x -n '__fish_riverctl_complete_no_subcommand' -a set-option -d 'Set the value of the specified option'
complete -c riverctl -x -n '__fish_riverctl_complete_no_subcommand' -a unset-option -d 'Unset the value of the specified option for the given output'
complete -c riverctl -x -n '__fish_riverctl_complete_no_subcommand' -a mod-option -d 'Add value to the value of the specified option'
complete -c riverctl -x -n '__fish_riverctl_complete_no_subcommand' -a output_title -d 'Changing this option changes the title of the Wayland and X11 backend outputs'
@ -71,8 +72,7 @@ complete -c riverctl -x -n '__fish_seen_subcommand_from map' -a
complete -c riverctl -x -n '__fish_seen_subcommand_from unmap' -a '-release'
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 strict'
complete -c riverctl -x -n '__fish_seen_subcommand_from declare-option' -a '-output -focused-output'
complete -c riverctl -x -n '__fish_seen_subcommand_from get-option' -a '-output -focused-output'
complete -c riverctl -x -n '__fish_seen_subcommand_from set-option' -a '-output -focused-output'
complete -c riverctl -x -n '__fish_seen_subcommand_from unset-option' -a '-output -focused-output'
complete -c riverctl -x -n '__fish_seen_subcommand_from mod-option' -a '-output -focused-output'

View File

@ -61,6 +61,7 @@ _riverctl() {
'declare-option:Declare a new option with the given type and initial value'
'get-option:Print the current value of the given option to stdout'
'set-option:Set the value of the specified option'
'unset-option:Unset the value of the specified option for the given output'
'mod-option:Add value to the value of the specified option'
'output_title:Changing this option changes the title of the Wayland and X11 backend outputs'
)
@ -87,13 +88,12 @@ _riverctl() {
unmap) _alternative 'arguments:optional:(-release)' ;;
attach-mode) _attach ;;
focus-follows-cursor) _focus_cursor ;;
declare-option) _river_opts ;;
get-option) _river_opts ;;
set-option) _river_opts ;;
unset-option) _river_opts ;;
mod-option) _river_opts ;;
*) return 0 ;;
esac
return 1
}