diff --git a/completions/bash/swaylock b/completions/bash/swaylock new file mode 100644 index 0000000..3392548 --- /dev/null +++ b/completions/bash/swaylock @@ -0,0 +1,66 @@ +# swaylock(1) completion + +_swaylock() +{ + local cur prev + _get_comp_words_by_ref -n : cur prev + + short=( + -h + -c + -s + -t + -v + -i + -u + -f + ) + + long=( + --help + --color + --scaling + --tiling + --version + --image + --no-unlock-indicator + --daemonize + ) + + scaling=( + 'stretch' + 'fill' + 'fit' + 'center' + 'tile' + ) + + case $prev in + -c|--color) + return + ;; + --scaling) + COMPREPLY=($(compgen -W "${scaling[*]}" -- "$cur")) + return + ;; + -i|--image) + if grep -q : <<< "$cur"; then + output="${cur%%:*}:" + cur="${cur#*:}" + else + output= + fi + COMPREPLY=($(compgen -f -- "$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 _swaylock swaylock diff --git a/completions/fish/swaylock.fish b/completions/fish/swaylock.fish new file mode 100644 index 0000000..99dff48 --- /dev/null +++ b/completions/fish/swaylock.fish @@ -0,0 +1,39 @@ +# swaylock(1) completion + +complete -c swaylock -s C -l config --description 'The config file to use. Default: $HOME/.swaylock/config, $XDG_CONFIG_HOME/swaylock/config, and SYSCONFDIR/swaylock/config.' +complete -c swaylock -s h -l help --description "Show help message and quit." +complete -c swaylock -s f -l daemonize --description "Fork into the background after spawning. Note: this is the default bahavior of i3lock." +complete -c swaylock -s v -l version --description "Show the version number and quit." +complete -c swaylock -s s -l socket --description "Use the specified socket path. Otherwise, swaymsg will as sway where the socket is (which is the value of $SWAYSOCK, then of $I350CK)." +complete -c swaylock -s e -l ignore-empty-password --description 'When an empty password is provided by the user, do not validate it.' + +# Appearance +complete -c swaylock -s u -l no-unlock-indicator --description "Disable the unlock indicator." +complete -c swaylock -s i -l image --description "Display the given image, optionally on the given output. Use -c to set a background color." +complete -c swaylock -s s -l scaling --description "Scaling mode for images: stretch, fill, fit, center, or tile." +complete -c swaylock -s t -l tiling --description "Same as --scaling=tile." +complete -c swaylock -s c -l color --description "Turn the screen into the given color. If -i is used, this sets the background of the image into the given color. Defaults to white (ffffff), or transparent (00000000) if an image is in use." +complete -c swaylock -l bs-hl-color --description 'Sets the color of backspace highlight segments.' +complete -c swaylock -l font --description 'Sets the font of the text inside the indicator.' +complete -c swaylock -l indicator-radius --description 'Sets the radius of the indicator to radius pixels. Default: 50' +complete -c swaylock -l indicator-thickness --description 'Sets the thickness of the indicator to thickness pixels. Default: 10' +complete -c swaylock -l inside-color --description 'Sets the color of the inside of the indicator when typing or idle.' +complete -c swaylock -l inside-clear-color --description 'Sets the color of the inside of the indicator when cleared.' +complete -c swaylock -l inside-ver-color --description 'Sets the color of the inside of the indicator when verifying.' +complete -c swaylock -l inside-wrong-color --description 'Sets the color of the inside of the indicator when invalid.' +complete -c swaylock -l key-hl-color --description 'Sets the color of key press highlight segments.' +complete -c swaylock -l line-color --description 'Sets the color of the lines that separate the inside and outside of the indicator when typing or idle.' +complete -c swaylock -l line-clear-color --description 'Sets the color of the lines that separate the inside and outside of the indicator when cleared.' +complete -c swaylock -l line-ver-color --description 'Sets the color of the lines that separate the inside and outside of the indicator when verifying.' +complete -c swaylock -l line-wrong-color --description 'Sets the color of the lines that separate the inside and outside of the indicator when invalid.' +complete -c swaylock -s n -l line-uses-inside --description 'Use the color of the inside of the indicator for the line separating the inside and outside of the indicator.' +complete -c swaylock -s r -l line-uses-ring --description 'Use the outer ring\'s color for the line separating the inside and outside of the indicator.' +complete -c swaylock -l ring-color --description 'Sets the color of the outside of the indicator when typing or idle.' +complete -c swaylock -l ring-clear-color --description 'Sets the color of the outside of the indicator when cleared.' +complete -c swaylock -l ring-ver-color --description 'Sets the color of the outside of the indicator when verifying.' +complete -c swaylock -l ring-wrong-color --description 'Sets the color of the outside of the indicator when invalid.' +complete -c swaylock -l separator-color --description 'Sets the color of the lines that separate highlight segments.' +complete -c swaylock -l text-color --description 'Sets the color of the text inside the indicator when typing or idle.' +complete -c swaylock -l text-clear-color --description 'Sets the color of the text inside the indicator when cleared.' +complete -c swaylock -l text-ver-color --description 'Sets the color of the text inside the indicator when verifying.' +complete -c swaylock -l text-wrong-color --description 'Sets the color of the text inside the indicator when invalid.' diff --git a/completions/zsh/_swaylock b/completions/zsh/_swaylock new file mode 100644 index 0000000..9bc84ec --- /dev/null +++ b/completions/zsh/_swaylock @@ -0,0 +1,40 @@ +#compdef swaylock +# +# Completion script for swaylock +# + +_arguments -s \ + '(-C --config)'{-C,--config}'[Path to the config file]:filename:_files' \ + '(-c --color)'{-c,--color}'[Turn the screen into the given color instead of white]:color:' \ + '(-e --ignore-empty-password)'{-e,--ignore-empty-password}'[When an empty password is provided, do not validate it]' \ + '(-f --daemonize)'{-f,--daemonize}'[Detach from the controlling terminal after locking]' \ + '(-h --help)'{-h,--help}'[Show help message and quit]' \ + '(-i --image)'{-i,--image}'[Display an image]:filename:_files' \ + '(-s --scaling)'{-s,--scaling}'[Scaling mode]:mode:(stretch fill fit center tile)' \ + '(-t --tiling)'{-t,--tiling}'[Same as --scaling=tile]' \ + '(-u --no-unlock-indicator)'{-u,--no-unlock-indicator}'[Disable the unlock indicator]' \ + '(-v --version)'{-v,--version}'[Show the version number and quit]' \ + '(--bs-hl-color)'--bs-hl-color'[Sets the color of backspace highlights segments]:color:' \ + '(--font)'--font'[Sets the font of the text]:font:' \ + '(--indicator-radius)'--indicator-radius'[Sets the indicator radius]:radius:' \ + '(--indicator-thickness)'--indicator-thickness'[Sets the indicator thickness]:thickness:' \ + '(--inside-color)'--inside-color'[Sets the color of the inside of the indicator]:color:' \ + '(--inside-clear-color)'--inside-clear-color'[Sets the color of the inside of the indicator when cleared]:color:' \ + '(--inside-clear-color)'--inside-clear-color'[Sets the color of the inside of the indicator when verifying]:color:' \ + '(--inside-wrong-color)'--inside-wrong-color'[Sets the color of the inside of the indicator when invalid]:color:' \ + '(--key-hl-color)'--key-hl-color'[Sets the color of the key press highlight segments]:color:' \ + '(--line-color)'--line-color'[Sets the color of the line between the inside and ring]:color:' \ + '(--line-clear-color)'--line-clear-color'[Sets the color of the line between the inside and ring when cleared]:color:' \ + '(--line-ver-color)'--line-ver-color'[Sets the color of the line between the inside and ring when verifying]:color:' \ + '(--line-wrong-color)'--line-wrong-color'[Sets the color of the line between the inside and ring when invalid]:color:' \ + '(-n --line-uses-inside)'{-n,--line-uses-inside}'[Use the inside color for the line between the inside and ring]' \ + '(-r --line-uses-ring)'{-r,--line--uses-ring}'[Use the ring color for the line between the inside and ring]' \ + '(--ring-color)'--ring-color'[Sets the color of the ring of the indicator]:color:' \ + '(--ring-clear-color)'--ring-clear-color'[Sets the color of the ring of the indicator when cleared]:color:' \ + '(--ring-ver-color)'--ring-ver-color'[Sets the color of the ring of the indicator when verifying]:color:' \ + '(--ring-wrong-color)'--ring-wrong-color'[Sets the color of the ring of the indicator when invalid]:color:' \ + '(--separator-color)'--separator-color'[Sets the color of the lines that separate highlight segments]:color:' \ + '(--text-color)'--text-color'[Sets the color of the text]:color:' \ + '(--text-clear-color)'--text-clear-color'[Sets the color of the text when cleared]:color:' \ + '(--text-ver-color)'--text-ver-color'[Sets the color of the text when verifying]:color:' \ + '(--text-wrong-color)'--text-wrong-color'[Sets the color of the text when invalid]:color:' \ No newline at end of file diff --git a/meson.build b/meson.build index b680c1a..b79dc41 100644 --- a/meson.build +++ b/meson.build @@ -199,3 +199,30 @@ if scdoc.found() ) endforeach endif + +if (get_option('zsh-completions')) + zsh_files = files( + 'completions/zsh/_swaylock', + ) + zsh_install_dir = datadir + '/zsh/site-functions' + + install_data(zsh_files, install_dir: zsh_install_dir) +endif + +if (get_option('bash-completions')) + bash_files = files( + 'completions/bash/swaylock', + ) + bash_install_dir = datadir + '/bash-completion/completions' + + install_data(bash_files, install_dir: bash_install_dir) +endif + +if (get_option('fish-completions')) + fish_files = files( + 'completions/fish/swaylock.fish', + ) + fish_install_dir = datadir + '/fish/completions' + + install_data(fish_files, install_dir: fish_install_dir) +endif diff --git a/meson_options.txt b/meson_options.txt index 60268b9..1d9fd5b 100644 --- a/meson_options.txt +++ b/meson_options.txt @@ -2,4 +2,3 @@ option('sway-version', type : 'string', description: 'The version string reporte 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.') -option('enable-tray', type: 'boolean', value: false, description: 'Enable support for swaybar tray')