mirror of
https://github.com/ErikReider/SwayNotificationCenter.git
synced 2024-10-03 20:07:52 +03:00
Terminal completions (#44)
* Added ZSH completions * Fixed single quote ending string * Added Bash completions * Added bash to meson.build * Added bash variable to meson_options.txt * Added fish shell completions
This commit is contained in:
parent
bf9309b193
commit
e85c2f5d6d
7
.gitignore
vendored
7
.gitignore
vendored
@ -3,5 +3,8 @@
|
||||
pkg
|
||||
build
|
||||
SwayNotificationCenter
|
||||
swaync
|
||||
swaync*
|
||||
./swaync
|
||||
./swaync*
|
||||
./src/swaync
|
||||
./src/swaync*
|
||||
swaync-git*
|
||||
|
38
completions/bash/swaync
Normal file
38
completions/bash/swaync
Normal file
@ -0,0 +1,38 @@
|
||||
_swaync() {
|
||||
local cur prev
|
||||
_get_comp_words_by_ref cur prev
|
||||
|
||||
short=(
|
||||
-h
|
||||
-s
|
||||
-c
|
||||
)
|
||||
|
||||
long=(
|
||||
--help
|
||||
--style
|
||||
--config
|
||||
)
|
||||
case $prev in
|
||||
-s | --style)
|
||||
_filedir
|
||||
return
|
||||
;;
|
||||
-c | --config)
|
||||
_filedir
|
||||
return
|
||||
;;
|
||||
esac
|
||||
|
||||
if [[ $cur == --* ]]; then
|
||||
COMPREPLY=($(compgen -W "${long[*]}" -- "$cur"))
|
||||
elif [[ $cur == -* ]]; then
|
||||
COMPREPLY=($(compgen -W "${short[*]}" -- "$cur"))
|
||||
COMPREPLY+=($(compgen -W "${long[*]}" -- "$cur"))
|
||||
else
|
||||
COMPREPLY=($(compgen -W "${short[*]}" -- "$cur"))
|
||||
COMPREPLY+=($(compgen -W "${long[*]}" -- "$cur"))
|
||||
COMPREPLY+=($(compgen -c -- "$cur"))
|
||||
fi
|
||||
|
||||
} && complete -F _swaync swaync
|
52
completions/bash/swaync-client
Normal file
52
completions/bash/swaync-client
Normal file
@ -0,0 +1,52 @@
|
||||
_swaync-client() {
|
||||
local cur prev
|
||||
_get_comp_words_by_ref cur prev
|
||||
|
||||
short=(
|
||||
-h
|
||||
-R
|
||||
-rs
|
||||
-t
|
||||
-d
|
||||
-D
|
||||
-c
|
||||
-C
|
||||
-sw
|
||||
-s
|
||||
)
|
||||
|
||||
long=(
|
||||
--help
|
||||
--reload-config
|
||||
--reload-css
|
||||
--toggle-panel
|
||||
--toggle-dnd
|
||||
--get-dnd
|
||||
--count
|
||||
--close-all
|
||||
--skip-wait
|
||||
--subscribe
|
||||
)
|
||||
case $prev in
|
||||
-s | --style)
|
||||
_filedir
|
||||
return
|
||||
;;
|
||||
-c | --config)
|
||||
_filedir
|
||||
return
|
||||
;;
|
||||
esac
|
||||
|
||||
if [[ $cur == --* ]]; then
|
||||
COMPREPLY=($(compgen -W "${long[*]}" -- "$cur"))
|
||||
elif [[ $cur == -* ]]; then
|
||||
COMPREPLY=($(compgen -W "${short[*]}" -- "$cur"))
|
||||
COMPREPLY+=($(compgen -W "${long[*]}" -- "$cur"))
|
||||
else
|
||||
COMPREPLY=($(compgen -W "${short[*]}" -- "$cur"))
|
||||
COMPREPLY+=($(compgen -W "${long[*]}" -- "$cur"))
|
||||
COMPREPLY+=($(compgen -c -- "$cur"))
|
||||
fi
|
||||
|
||||
} && complete -F _swaync-client swaync-client
|
11
completions/fish/swaync-client.fish
Normal file
11
completions/fish/swaync-client.fish
Normal file
@ -0,0 +1,11 @@
|
||||
complete -f -c swaync-client
|
||||
complete -c swaync-client -s h -l help --description "Show help options"
|
||||
complete -c swaync-client -s R -l reload-config --description "Reload the config file" -r
|
||||
complete -c swaync-client -s rs -l reload-css --description "Reload the css file. Location change requires restart" -r
|
||||
complete -c swaync-client -s t -l toggle-panel --description "Toggle the notificaion panel" -r
|
||||
complete -c swaync-client -s d -l toggle-dnd --description "Toggle and print the current dnd state" -r
|
||||
complete -c swaync-client -s D -l get-dnd --description "Print the current dnd state" -r
|
||||
complete -c swaync-client -s c -l count --description "Print the current notificaion count" -r
|
||||
complete -c swaync-client -s C -l close-all --description "Closes all notifications" -r
|
||||
complete -c swaync-client -s sw -l skip-wait --description "Doesn't wait when swaync hasn't been started" -r
|
||||
complete -c swaync-client -s s -l subscribe --description "Subscribe to notificaion add and close events" -r
|
4
completions/fish/swaync.fish
Normal file
4
completions/fish/swaync.fish
Normal file
@ -0,0 +1,4 @@
|
||||
complete -f -c swaync
|
||||
complete -c swaync -s h -l help --description "Show help options"
|
||||
complete -c swaync -s s -l style --description "Use a custom Stylesheet file" -r
|
||||
complete -c swaync -s c -l config --description "Use a custom config file" -r
|
6
completions/zsh/_swaync
Normal file
6
completions/zsh/_swaync
Normal file
@ -0,0 +1,6 @@
|
||||
#compdef swaync
|
||||
|
||||
_arguments -s \
|
||||
'(-h --help)'{-h,--help}'[Show help options]' \
|
||||
'(-s --style)'{-s,--style}'[Use a custom Stylesheet file]:files:_files' \
|
||||
'(-c --config)'{-c,--config}'[Use a custom config file]:files:_files' \
|
13
completions/zsh/_swaync-client
Normal file
13
completions/zsh/_swaync-client
Normal file
@ -0,0 +1,13 @@
|
||||
#compdef swaync-client
|
||||
|
||||
_arguments -s \
|
||||
'(-h --help)'{-h,--help}'[Show help options]' \
|
||||
'(-R --reload-config)'{-R --reload-config}'[Reload the config file]' \
|
||||
'(-rs --reload-css)'{-rs --reload-css}'[Reload the css file. Location change requires restart]' \
|
||||
'(-t --toggle-panel)'{-t --toggle-panel}'[Toggle the notificaion panel]' \
|
||||
'(-d --toggle-dnd)'{-d --toggle-dnd}'[Toggle and print the current dnd state]' \
|
||||
'(-D --get-dnd)'{-D --get-dnd}'[Print the current dnd state]' \
|
||||
'(-c --count)'{-c --count}'[Print the current notificaion count]' \
|
||||
'(-C --close-all)'{-C --close-all}'[Closes all notifications]' \
|
||||
'(-sw --skip-wait)'{-sw --skip-wait}"[Doesn't wait when swaync hasn't been started]" \
|
||||
'(-s --subscribe)'{-s --subscribe}'[Subscribe to notificaion add and close events]' \
|
3
meson_options.txt
Normal file
3
meson_options.txt
Normal file
@ -0,0 +1,3 @@
|
||||
option('zsh-completions', type: 'boolean', value: true, description: 'Install zsh shell completions.')
|
||||
option('bash-completions', type: 'boolean', value: true, description: 'Install bash shell completions.')
|
||||
option('fish-completions', type: 'boolean', value: true, description: 'Install fish shell completions.')
|
@ -59,3 +59,56 @@ executable('swaync-client',
|
||||
|
||||
install_data('style.css', install_dir : join_paths(sysconfdir, 'xdg/swaync'))
|
||||
install_data('config.json', install_dir : join_paths(sysconfdir, 'xdg/swaync'))
|
||||
|
||||
datadir = get_option('datadir')
|
||||
|
||||
# Zsh completion
|
||||
if get_option('zsh-completions')
|
||||
zsh_files = files(
|
||||
'../completions/zsh/_swaync',
|
||||
'../completions/zsh/_swaync-client',
|
||||
)
|
||||
zsh_install_dir = join_paths(datadir, 'zsh', 'site-functions')
|
||||
|
||||
install_data(zsh_files, install_dir: zsh_install_dir)
|
||||
endif
|
||||
|
||||
# Bash completion
|
||||
bash_comp = dependency('bash-completion', required: false)
|
||||
if get_option('bash-completions')
|
||||
bash_files = files(
|
||||
'../completions/bash/swaync',
|
||||
'../completions/bash/swaync-client',
|
||||
)
|
||||
|
||||
if bash_comp.found()
|
||||
bash_install_dir = bash_comp.get_variable(
|
||||
pkgconfig: 'completionsdir',
|
||||
pkgconfig_define: ['datadir', datadir]
|
||||
)
|
||||
else
|
||||
bash_install_dir = join_paths(datadir, 'bash-completion', 'completions')
|
||||
endif
|
||||
|
||||
install_data(bash_files, install_dir: bash_install_dir)
|
||||
endif
|
||||
|
||||
# Fish completion
|
||||
fish_comp = dependency('fish', required: false)
|
||||
if get_option('fish-completions')
|
||||
fish_files = files(
|
||||
'../completions/fish/swaync.fish',
|
||||
'../completions/fish/swaync-client.fish',
|
||||
)
|
||||
|
||||
if fish_comp.found()
|
||||
fish_install_dir = fish_comp.get_variable(
|
||||
pkgconfig: 'completionsdir',
|
||||
pkgconfig_define: ['datadir', datadir]
|
||||
)
|
||||
else
|
||||
fish_install_dir = join_paths(datadir, 'fish', 'vendor_completions.d')
|
||||
endif
|
||||
|
||||
install_data(fish_files, install_dir: fish_install_dir)
|
||||
endif
|
||||
|
Loading…
Reference in New Issue
Block a user