Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 22 additions & 6 deletions scripts/completions/zsh-completions/_wl-mirror
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
#compdef wl-mirror

_wl_mirror_outputs() {
if [[ "$XDG_CURRENT_DESKTOP" == "sway" ]]; then
swaymsg -t get_outputs | sed -n '/^[[:space:]]*"name":/s/^.*"\([^"]*\)",/\1/p'
fi
case "$XDG_CURRENT_DESKTOP" in
sway|swayfx)
swaymsg -t get_outputs | sed -n '/^[[:space:]]*"name":/s/^.*"\([^"]*\)",/\1/p'
;;
*)
_message "Output completion is not supported on '${XDG_CURRENT_DESKTOP}'"
esac
}

_wl_mirror_transforms() {
Expand All @@ -19,15 +23,28 @@ _wl_mirror_scalings() {
}

_wl_mirror() {
if [ -z "${XDG_CURRENT_DESKTOP+x}" ]; then
_message "Please set XDG_CURRENT_DESKTOP to enable completion of outputs"
else
case "$XDG_CURRENT_DESKTOP" in
sway|swayfx) ;;
*) _message "Output completion is not supported on '${XDG_CURRENT_DESKTOP}'"
esac
fi

local -a outputs transforms backends scalings
outputs=("${(@f)$(_wl_mirror_outputs)}")
transforms=("${(@f)$(_wl_mirror_transforms)}")
backends=("${(@f)$(_wl_mirror_backends)}")
scalings=("${(@f)$(_wl_mirror_scalings)}")

local -a options
options=(
'1:output:_values "output" $outputs'
if [ -n "${outputs}" ]; then
options+=('1:output:_values "output" $outputs')
options+='--fullscreen-output[set fullscreen target output, implies --fullscreen]:output:_values "output" $outputs'
fi
Comment thread
mazunki marked this conversation as resolved.

options+=(
'(-h --help)'{-h,--help}'[show this help]'
'(-V --version)'{-V,--version}'[print version]'
'(-v --verbose --no-verbose)'{-v,--verbose}'[enable debug logging]'
Expand All @@ -41,7 +58,6 @@ _wl_mirror() {
'--toggle-freeze[toggle freeze state of screen capture]'
'(-F --fullscreen --no-fullscreen --fullscreen-output --no-fullscreen-output)'{-F,--fullscreen}'[display wl-mirror as fullscreen]'
'--no-fullscreen[display wl-mirror as a window]'
'--fullscreen-output[set fullscreen target output, implies --fullscreen]:output:_values "output" $outputs'
'--no-fullscreen-output[unset fullscreen target output, implies --no-fullscreen]'
'-s[scaling method]:scaling method:_values "scaling" $scalings'
'-b[use a specific backend]:backend:_values "backend" $backends'
Expand Down
29 changes: 18 additions & 11 deletions scripts/completions/zsh-completions/_wl-present
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
#compdef wl-present

_wl_mirror_outputs() {
if [[ "$XDG_CURRENT_DESKTOP" == "sway" ]]; then
swaymsg -t get_outputs | sed -n '/^[[:space:]]*"name":/s/^.*"\([^"]*\)",/\1/p'
fi
case "$XDG_CURRENT_DESKTOP" in
sway|swayfx)
swaymsg -t get_outputs | sed -n '/^[[:space:]]*"name":/s/^.*"\([^"]*\)",/\1/p'
;;
*)
_message "Output completion is not supported on '${XDG_CURRENT_DESKTOP}'"
esac
}

_wl_mirror_transforms() {
Expand All @@ -19,20 +23,21 @@ _wl_mirror_scalings() {
}

_wl_present() {
local -a outputs transforms backends scalings
outputs=("${(@f)$(_wl_mirror_outputs)}")
transforms=("${(@f)$(_wl_mirror_transforms)}")
backends=("${(@f)$(_wl_mirror_backends)}")
scalings=("${(@f)$(_wl_mirror_scalings)}")

if [ -z "${XDG_CURRENT_DESKTOP+x}" ]; then
_message "Please set XDG_CURRENT_DESKTOP to enable completion of outputs"
else
case "$XDG_CURRENT_DESKTOP" in
sway|swayfx) ;;
*) _message "Output completion is not supported on '${XDG_CURRENT_DESKTOP}'"
esac
fi

local -a outputs transforms backends scalings
outputs=("${(@f)$(_wl_mirror_outputs)}")
transforms=("${(@f)$(_wl_mirror_transforms)}")
backends=("${(@f)$(_wl_mirror_backends)}")
scalings=("${(@f)$(_wl_mirror_scalings)}")


local -a commands options
commands=(
'help:show this help'
Expand Down Expand Up @@ -71,7 +76,9 @@ _wl_present() {
;;
set-output)
if (( CURRENT == 2 )); then
_values output $outputs
if [ -z "${#outputs}" ]; then
_values output $outputs
fi
Comment thread
mazunki marked this conversation as resolved.
fi
;;
set-region)
Expand Down