diff options
author | Eric Engestrom <eric.engestrom@intel.com> | 2018-07-27 16:31:39 +0100 |
---|---|---|
committer | Eric Engestrom <eric.engestrom@intel.com> | 2018-07-30 15:56:15 +0100 |
commit | c4b4da5dc4ba9c68ff28ba2a01566b760adf1f55 (patch) | |
tree | 635a2b13e8f7ee6b48a662bd55abc31443318642 /completions | |
parent | bash: add completion for swaylock (diff) | |
download | sway-c4b4da5dc4ba9c68ff28ba2a01566b760adf1f55.tar.gz sway-c4b4da5dc4ba9c68ff28ba2a01566b760adf1f55.tar.zst sway-c4b4da5dc4ba9c68ff28ba2a01566b760adf1f55.zip |
bash: add completion for swayidle
Diffstat (limited to 'completions')
-rw-r--r-- | completions/bash/swayidle | 48 |
1 files changed, 48 insertions, 0 deletions
diff --git a/completions/bash/swayidle b/completions/bash/swayidle new file mode 100644 index 00000000..a0cdc8b2 --- /dev/null +++ b/completions/bash/swayidle | |||
@@ -0,0 +1,48 @@ | |||
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 | ||