~emersion/public-inbox

wlr-randr: Add bash completion v1 PROPOSED

kiasoc5: 1
 Add bash completion

 1 files changed, 43 insertions(+), 0 deletions(-)
Export patchset (mbox)
How do I use this?

Copy & paste the following snippet into your terminal to import this patchset into git:

curl -s https://lists.sr.ht/~emersion/public-inbox/patches/35748/mbox | git am -3
Learn more about email & git

[PATCH wlr-randr] Add bash completion Export this patch

This is inspired by bash-completion's xrandr completion, which is GPL2.

If this is not license compatible I can send this to bash-completion instead.

---
 bash_completion.d/wlr-randr | 43 +++++++++++++++++++++++++++++++++++++
 1 file changed, 43 insertions(+)
 create mode 100644 bash_completion.d/wlr-randr

diff --git a/bash_completion.d/wlr-randr b/bash_completion.d/wlr-randr
new file mode 100644
index 0000000..0d9b0ac
--- /dev/null
@@ -0,0 +1,43 @@
# bash completion for wlr-randr                               -*- shell-script -*-

_wlr-randr()
{
    local cur prev words cword
    _init_completion || return

    case "$prev" in
        --help|--dryrun|--on|--off|--preferred|--pos|--scale|--custom-mode)
            return
            ;;
        --output)
            local outputs=$( "$1" | awk '/^[^ ]/ {print $1}')
            COMPREPLY=( $( compgen -W "$outputs" -- "$cur" ) )
            return
            ;;
        --mode)
            local i output
            for (( i=1; i < cword; i++ )); do
                if [[ "${words[i]}" == --output ]]; then
                    output=${words[i+1]}
                    break
                fi
            done
            if [[ $output ]]; then
                local modes=$( "$1" | command sed -e "/$output/,/^[^[:space:]]/"' !d' -e '/px\|Hz/ !d' -e 's/\([^[:space:]]\)[[:space:]].*/\1/' )
                COMPREPLY=( $( compgen -W "$modes" -- "$cur" ) )
            fi
            return
            ;;
        --transform)
            COMPREPLY=( $( compgen -W 'normal 90 180 270 flipped flipped-90 flipped-180 flipped-270' -- \
                "$cur" ) )
            return
            ;;
    esac

    COMPREPLY=( $( compgen -W '$( "$1" --help 2>&1 |
        command sed "s/|/\n/g" |  _parse_help - )' -- "$cur" ) )
} &&
complete -F _wlr-randr wlr-randr

# ex: filetype=sh

base-commit: d17786cf05f22a5ccbd65ce0cfdf0bab1bfc0623
-- 
2.37.3