aboutsummaryrefslogtreecommitdiff
path: root/completions/bash/swayidle
diff options
context:
space:
mode:
authorFurkan Sahin <furkan-dev@proton.me>2018-07-30 13:11:20 -0400
committerFurkan Sahin <furkan-dev@proton.me>2018-07-30 13:11:20 -0400
commit9ba6b91dc63776222853f2658bff7c602682eeb6 (patch)
tree742714aeaff5118afabf0cb2179040655510e9df /completions/bash/swayidle
parentd8be0f1730d336a8f2df93241453bfc2cf12c951 (diff)
parent3d363f6a36d6e5f4690ab4a4833cddf7a5353db0 (diff)
Merge pull request #2387 from 1ace/feature/bash-completion
bash completion
Diffstat (limited to 'completions/bash/swayidle')
-rw-r--r--completions/bash/swayidle48
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 @@
+# swaymsg(1) completion
+
+_swayidle()
+{
+ local cur prev
+ _get_comp_words_by_ref -n : cur prev
+ local prev2=${COMP_WORDS[COMP_CWORD-2]}
+ local prev3=${COMP_WORDS[COMP_CWORD-3]}
+
+ events=(
+ 'timeout'
+ 'before-sleep'
+ )
+
+ short=(
+ -h
+ -d
+ )
+
+ if [ "$prev" = timeout ]; then
+ # timeout <timeout>
+ return
+ elif [ "$prev2" = timeout ]; then
+ # timeout <timeout> <timeout command>
+ COMPREPLY=($(compgen -c -- "$cur"))
+ return
+ elif [ "$prev3" = timeout ]; then
+ # timeout <timeout> <timeout command> [resume <resume command>]
+ COMPREPLY=(resume)
+ # optional argument; no return here as user may skip 'resume'
+ fi
+
+ case "$prev" in
+ resume)
+ COMPREPLY=($(compgen -c -- "$cur"))
+ return
+ ;;
+ before-sleep)
+ COMPREPLY=($(compgen -c -- "$cur"))
+ return
+ ;;
+ esac
+
+ COMPREPLY+=($(compgen -W "${events[*]}" -- "$cur"))
+ COMPREPLY+=($(compgen -W "${short[*]}" -- "$cur"))
+
+} &&
+complete -F _swayidle swayidle