summaryrefslogtreecommitdiff
path: root/completions/xrandr
blob: 3616429868ab419fd4b39818ae88aec2abc71f75 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
# bash completion for xrandr                               -*- shell-script -*-

_xrandr()
{
    local cur prev words cword
    _init_completion || return

    local output modes

    case $prev in
        --output|--left-of|--right-of|--above|--below|--same-as)
            local outputs=$(xrandr|awk '/connected/ {print $1}')
            COMPREPLY=( $(compgen -W "$outputs" -- "$cur"))
            return 0
            ;;
        --mode)
            for(( i = 1; i < cword; i++ )); do
                if [[ "${words[i]}" == "--output" ]]; then
                    output=${words[i+1]}
                    break
                fi
            done
            modes=$(xrandr|sed -e "1,/$output/ d" \
                -e "/connected/,$ d"|awk '{print $1}')
            COMPREPLY=( $( compgen -W "$modes" -- "$cur"))
            return 0
            ;;
        -o|--orientation)
            COMPREPLY=( $( compgen -W 'normal inverted left right 0 1 2 3' -- \
                "$cur" ) )
            return 0
            ;;
        --reflect)
            COMPREPLY=( $( compgen -W 'normal x y xy' -- \
                "$cur" ) )
            return 0
            ;;
        --rotate)
            COMPREPLY=( $( compgen -W 'normal inverted left right' -- \
                "$cur" ) )
            return 0
            ;;
    esac

    case $cur in
        *)
            COMPREPLY=( $(compgen -W '-display -help --orientation --query \
                --size --rate --version -x -y --screen --verbose --dryrun \
                --q1 --q12 --nograb --prop --properties --fb --fbmm --dpi \
                --output --auto --mode --preferred --pos --rate --refresh \
                --reflect --rotate --left-of --right-of --above --below \
                --same-as --set --scale --transform --off --crtc --panning \
                --gamma --brightness --primary --noprimary --newmode --rmmode \
                --addmode --delmode' -- "$cur") )
            return 0
            ;;
    esac
} &&
complete -F _xrandr xrandr

# ex: ts=4 sw=4 et filetype=sh