diff --git a/build/utils.sh b/build/utils.sh index 26c7abe..9cb3b5c 100755 --- a/build/utils.sh +++ b/build/utils.sh @@ -61,7 +61,7 @@ init_build_dir() { prepare_install() { cd "${BUILD_DIR}" mkdir -p \ - "${INSTALL_ROOT}${PREFIX}"/share/{man/man1,metainfo,web-greeter,xgreeters} \ + "${INSTALL_ROOT}${PREFIX}"/share/{man/man1,metainfo,web-greeter,xgreeters,zsh/vendor-completions,bash-completion/completions} \ "${INSTALL_ROOT}"/etc/{lightdm,xdg/lightdm/lightdm.conf.d} # Themes @@ -72,6 +72,10 @@ prepare_install() { # Man Page cp "${BUILD_DIR}/dist/${PKGNAME}.1" "${INSTALL_ROOT}${PREFIX}/share/man/man1" + # Command line completions + cp "${BUILD_DIR}/dist/${PKGNAME}-bash" "${INSTALL_ROOT}${PREFIX}/share/bash-completion/completions/${PKGNAME}" + cp "${BUILD_DIR}/dist/${PKGNAME}-zsh" "${INSTALL_ROOT}${PREFIX}/share/zsh/vendor-completions/_${PKGNAME}" + # Greeter Config cp "${BUILD_DIR}/dist/${PKGNAME}.yml" "${INSTALL_ROOT}/etc/lightdm" diff --git a/dist/web-greeter-bash b/dist/web-greeter-bash new file mode 100644 index 0000000..ab51e11 --- /dev/null +++ b/dist/web-greeter-bash @@ -0,0 +1,20 @@ +#!/usr/bin/env bash +# bash completion for web-greeter + +_web-greeter() { + local cur="${COMP_WORDS[COMP_CWORD]}" + local last="${COMP_WORDS[COMP_CWORD - 1]}" + local xpat='!*.jpg' + local options='--debug --normal --list --theme --help -h --version -v' + + case "${last}" in + --theme) + options=$(ls -1d /usr/share/web-greeter/themes/*/ | cut -c 1- | + rev | cut -c 2- | rev | sort | sed 's/\/usr\/share\/web-greeter\/themes\///') + ;; + esac + + COMPREPLY=( $(compgen -W "${options}" -- "${cur}") ) +} + +complete -F _web-greeter web-greeter diff --git a/dist/web-greeter-zsh b/dist/web-greeter-zsh new file mode 100644 index 0000000..3de4b0b --- /dev/null +++ b/dist/web-greeter-zsh @@ -0,0 +1,22 @@ +#compdef web-greeter + +_webgreeter() { + integer ret=1 + local -a args + local themes=$(ls -1d /usr/share/web-greeter/themes/*/ | cut -c 1- | + rev | cut -c 2- | rev | sort | sed 's/\/usr\/share\/web-greeter\/themes\///') + args+=( + '--debug[Runs the greeter in debug mode]' + '--normal[Runs in non-debug mode]' + '--list[Lists available themes]' + "--theme[Sets the theme to use]:theme:(${themes})" + '--help[Show help]' + '-h[Show help]' + '--version[Print program version]' + '-v[Print program version]' + ) + _arguments $args[@] && ret=0 + return ret +} + +_webgreeter