diff --git a/CMakeLists.txt b/CMakeLists.txt index 3667da7..c2ee932 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -26,3 +26,29 @@ install(TARGETS ydotool DESTINATION ${CMAKE_INSTALL_BINDIR}) add_subdirectory(Daemon) add_subdirectory(manpage) + +# Install bash completion scripts +install(FILES + ${CMAKE_CURRENT_SOURCE_DIR}/completions/ydotool-completion.bash + DESTINATION ${CMAKE_INSTALL_DATADIR}/bash-completion/completions + RENAME ydotool +) + +install(FILES + ${CMAKE_CURRENT_SOURCE_DIR}/completions/ydotoold-completion.bash + DESTINATION ${CMAKE_INSTALL_DATADIR}/bash-completion/completions + RENAME ydotoold +) + +# Install zsh completion scripts +install(FILES + ${CMAKE_CURRENT_SOURCE_DIR}/completions/ydotool-completion.zsh + DESTINATION ${CMAKE_INSTALL_DATADIR}/zsh/site-functions + RENAME _ydotool +) + +install(FILES + ${CMAKE_CURRENT_SOURCE_DIR}/completions/ydotoold-completion.zsh + DESTINATION ${CMAKE_INSTALL_DATADIR}/zsh/site-functions + RENAME _ydotoold +) diff --git a/completions/ydotool-completion.bash b/completions/ydotool-completion.bash new file mode 100644 index 0000000..7c70cbd --- /dev/null +++ b/completions/ydotool-completion.bash @@ -0,0 +1,11 @@ +# bash completion for ydotool -*- shell-script -*- + +_ydotool_completions() { + local cur="${COMP_WORDS[COMP_CWORD]}" + local options="-h --help click mousemove type key debug bakers stdin" + COMPREPLY=($(compgen -W "$options" -- "$cur")) +} + +complete -F _ydotool_completions ydotool + +# ex: ts=4 sw=4 et filetype=sh diff --git a/completions/ydotool-completion.zsh b/completions/ydotool-completion.zsh new file mode 100644 index 0000000..386f874 --- /dev/null +++ b/completions/ydotool-completion.zsh @@ -0,0 +1,12 @@ +#compdef ydotool + +_ydotool() { + local -a commands + commands=(click mousemove type key debug bakers stdin) + + _arguments \ + '(-h --help)'{-h,--help}'[Show help message]' \ + '1:command:_values "commands" $commands[@]' +} + +_ydotool "$@" diff --git a/completions/ydotoold-completion.bash b/completions/ydotoold-completion.bash new file mode 100644 index 0000000..11595b6 --- /dev/null +++ b/completions/ydotoold-completion.bash @@ -0,0 +1,11 @@ +# bash completion for ydotoold -*- shell-script -*- + +_ydotoold_completions() { + local cur="${COMP_WORDS[COMP_CWORD]}" + local options="-h --help -V --version -p --socket-path -P --socket-perm -m --mouse-off -k --keyboard-off -T --touch-on" + COMPREPLY=($(compgen -W "$options" -- "$cur")) +} + +complete -F _ydotoold_completions ydotoold + +# ex: ts=4 sw=4 et filetype=sh diff --git a/completions/ydotoold-completion.zsh b/completions/ydotoold-completion.zsh new file mode 100644 index 0000000..ebde3c5 --- /dev/null +++ b/completions/ydotoold-completion.zsh @@ -0,0 +1,15 @@ +#compdef ydotoold + +_ydotoold() { + _arguments \ + '(-h --help)'{-h,--help}'[Display help and exit]' \ + '(-V --version)'{-V,--version}'[Show version information]' \ + '(-p --socket-path)'{-p,--socket-path}'[Custom socket path]:path:_files' \ + '(-P --socket-perm)'{-P,--socket-perm}'[Socket permission (default 0600)]:permission:' \ + '(-o --socket-own)'{-o,--socket-own}'[Socket ownership]:ownership:' \ + '(-m --mouse-off)'{-m,--mouse-off}'[Disable mouse (EV_REL)]' \ + '(-k --keyboard-off)'{-k,--keyboard-off}'[Disable keyboard (EV_KEY)]' \ + '(-T --touch-on)'{-T,--touch-on}'[Enable touchscreen (EV_ABS)]' +} + +_ydotoold "$@"