diff options
Diffstat (limited to 'completions/bash')
-rw-r--r-- | completions/bash/swaybar | 44 | ||||
-rw-r--r-- | completions/bash/swayidle | 48 |
2 files changed, 44 insertions, 48 deletions
diff --git a/completions/bash/swaybar b/completions/bash/swaybar new file mode 100644 index 00000000..1e085c65 --- /dev/null +++ b/completions/bash/swaybar | |||
@@ -0,0 +1,44 @@ | |||
1 | # swaybar(1) completion | ||
2 | |||
3 | _swaybar() | ||
4 | { | ||
5 | local cur prev | ||
6 | _get_comp_words_by_ref cur prev | ||
7 | |||
8 | short=( | ||
9 | -h | ||
10 | -v | ||
11 | -s | ||
12 | -b | ||
13 | -d | ||
14 | ) | ||
15 | |||
16 | long=( | ||
17 | --help | ||
18 | --version | ||
19 | --socket | ||
20 | --bar_id | ||
21 | --debug | ||
22 | ) | ||
23 | |||
24 | case $prev in | ||
25 | -s|--socket) | ||
26 | _filedir | ||
27 | return | ||
28 | ;; | ||
29 | -b|--bar_id) | ||
30 | bars=($(swaymsg -t get_bar_config | jq -r '.[]')) | ||
31 | COMPREPLY=($(compgen -W "${bars[*]}" -- "$cur")) | ||
32 | return | ||
33 | ;; | ||
34 | esac | ||
35 | |||
36 | if [[ $cur == --* ]]; then | ||
37 | COMPREPLY=($(compgen -W "${long[*]}" -- "$cur")) | ||
38 | else | ||
39 | COMPREPLY=($(compgen -W "${short[*]}" -- "$cur")) | ||
40 | COMPREPLY+=($(compgen -W "${long[*]}" -- "$cur")) | ||
41 | fi | ||
42 | |||
43 | } && | ||
44 | complete -F _swaybar swaybar | ||
diff --git a/completions/bash/swayidle b/completions/bash/swayidle deleted file mode 100644 index a0cdc8b2..00000000 --- a/completions/bash/swayidle +++ /dev/null | |||
@@ -1,48 +0,0 @@ | |||
1 | # swaymsg(1) completion | ||
2 | |||
3 | _swayidle() | ||
4 | { | ||
5 | local cur prev | ||
6 | _get_comp_words_by_ref -n : cur prev | ||
7 | local prev2=${COMP_WORDS[COMP_CWORD-2]} | ||
8 | local prev3=${COMP_WORDS[COMP_CWORD-3]} | ||
9 | |||
10 | events=( | ||
11 | 'timeout' | ||
12 | 'before-sleep' | ||
13 | ) | ||
14 | |||
15 | short=( | ||
16 | -h | ||
17 | -d | ||
18 | ) | ||
19 | |||
20 | if [ "$prev" = timeout ]; then | ||
21 | # timeout <timeout> | ||
22 | return | ||
23 | elif [ "$prev2" = timeout ]; then | ||
24 | # timeout <timeout> <timeout command> | ||
25 | COMPREPLY=($(compgen -c -- "$cur")) | ||
26 | return | ||
27 | elif [ "$prev3" = timeout ]; then | ||
28 | # timeout <timeout> <timeout command> [resume <resume command>] | ||
29 | COMPREPLY=(resume) | ||
30 | # optional argument; no return here as user may skip 'resume' | ||
31 | fi | ||
32 | |||
33 | case "$prev" in | ||
34 | resume) | ||
35 | COMPREPLY=($(compgen -c -- "$cur")) | ||
36 | return | ||
37 | ;; | ||
38 | before-sleep) | ||
39 | COMPREPLY=($(compgen -c -- "$cur")) | ||
40 | return | ||
41 | ;; | ||
42 | esac | ||
43 | |||
44 | COMPREPLY+=($(compgen -W "${events[*]}" -- "$cur")) | ||
45 | COMPREPLY+=($(compgen -W "${short[*]}" -- "$cur")) | ||
46 | |||
47 | } && | ||
48 | complete -F _swayidle swayidle | ||