2019-01-01 05:17:05 +11:00
|
|
|
# swaybar(1) completion
|
|
|
|
|
|
|
|
_swaybar()
|
|
|
|
{
|
2022-08-15 14:54:07 +10:00
|
|
|
local cur prev
|
2019-01-01 05:17:05 +11:00
|
|
|
_get_comp_words_by_ref cur prev
|
|
|
|
|
|
|
|
short=(
|
|
|
|
-h
|
|
|
|
-v
|
|
|
|
-s
|
|
|
|
-b
|
|
|
|
-d
|
|
|
|
)
|
|
|
|
|
|
|
|
long=(
|
|
|
|
--help
|
|
|
|
--version
|
|
|
|
--socket
|
|
|
|
--bar_id
|
|
|
|
--debug
|
|
|
|
)
|
|
|
|
|
|
|
|
case $prev in
|
|
|
|
-s|--socket)
|
|
|
|
_filedir
|
|
|
|
return
|
|
|
|
;;
|
|
|
|
-b|--bar_id)
|
2019-01-03 08:50:51 +11:00
|
|
|
bars=($(swaymsg -t get_bar_config | jq -r '.[]'))
|
2019-01-01 05:17:05 +11:00
|
|
|
COMPREPLY=($(compgen -W "${bars[*]}" -- "$cur"))
|
|
|
|
return
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
|
|
|
|
if [[ $cur == --* ]]; then
|
|
|
|
COMPREPLY=($(compgen -W "${long[*]}" -- "$cur"))
|
|
|
|
else
|
|
|
|
COMPREPLY=($(compgen -W "${short[*]}" -- "$cur"))
|
|
|
|
COMPREPLY+=($(compgen -W "${long[*]}" -- "$cur"))
|
|
|
|
fi
|
|
|
|
|
|
|
|
} &&
|
|
|
|
complete -F _swaybar swaybar
|