spiegel-keyman/linux/keyman-config/km-package-get.bash-completion
Eberhard Beilharz 5f5054b93c
chore(linux): Fix lintian warnings
- add rudimentary man page for keyman-system-service
- remove hashbang for bash completion files
- reword description for keyman-system-service

This fixes these lintian warnings:
keyman-system-service: description-is-pkg-name Keyman system service
keyman: bash-completion-with-hashbang /usr/bin/env bash
        [usr/share/bash-completion/completions/km-config:1]
keyman-system-service: no-manual-page
        [usr/libexec/keyman-system-service]
2023-06-05 17:18:55 +02:00

40 lines
1.5 KiB
Text

# shellcheck disable=SC2148
# No hashbang for bash completion scripts! They are intended to be sourced, not executed.
_km-package-get_completions()
{
local cur opts cache pkg_install_path
COMPREPLY=()
cur="${COMP_WORDS[COMP_CWORD]}"
opts="-h --help -v --verbose -vv --veryverbose --version"
cache=${XDG_CACHE_HOME:-~/.cache}/keyman/kmpdirlist
if [[ ${cur} == -* ]] ; then
# shellcheck disable=SC2207
COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") )
return 0
fi
words=""
if [[ ! -e $cache ]] ; then
# NOTE: identical code in `km-package-install.bash-completion`.
# Unfortunately with bash completion scripts it's not possible to factor out
# common code.
if [[ -e ./km-package-install ]]; then
pkg_install_path='./km-package-install'
else
pkg_install_path='/usr/bin/km-package-install'
fi
python3 -c "from importlib.machinery import SourceFileLoader;from importlib.util import module_from_spec, spec_from_loader;loader = SourceFileLoader('km_package_install', $pkg_install_path);spec = spec_from_loader(loader.name, loader);mod = module_from_spec(spec);loader.exec_module(mod);mod.list_keyboards()"
fi
if [[ -r $cache ]] ; then
while read -r file; do words="${words} ${file}"; done < "$cache"
# shellcheck disable=SC2207
COMPREPLY=($(compgen -W "${words}" -- "${cur}"))
return 0
fi
}
complete -F _km-package-get_completions km-package-get