1 # shellcheck shell=bash
2 # homectl(1) completion -*- shell-script -*-
3 # SPDX-License-Identifier: LGPL-2.1-or-later
5 # This file is part of systemd.
7 # systemd is free software; you can redistribute it and/or modify it
8 # under the terms of the GNU Lesser General Public License as published by
9 # the Free Software Foundation; either version 2.1 of the License, or
10 # (at your option) any later version.
12 # systemd is distributed in the hope that it will be useful, but
13 # WITHOUT ANY WARRANTY; without even the implied warranty of
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 # General Public License for more details.
17 # You should have received a copy of the GNU Lesser General Public License
18 # along with systemd; If not, see <https://www.gnu.org/licenses/>.
21 local w word=$1; shift
23 [[ $w = "$word" ]] && return
29 machinectl list --full --no-legend --no-pager 2>/dev/null |
30 { while read a b; do echo " $a"; done; };
34 homectl --no-pager --no-legend list 2>/dev/null
39 local cur=${COMP_WORDS[COMP_CWORD]} prev=${COMP_WORDS[COMP_CWORD-1]}
42 [STANDALONE]='-h --help --version
43 --no-pager --no-legend --no-ask-password
71 --enforce-password-policy
75 --password-change-warn
76 --password-change-inactive
91 --luks-offline-discard
94 --luks-volume-key-size
96 --luks-pbkdf-hash-algorithm
97 --luks-pbkdf-force-iterations
98 --luks-pbkdf-time-cost
99 --luks-pbkdf-memory-cost
100 --luks-pbkdf-parallel-threads
121 if __contains_word "$prev" ${OPTS[ARG]}; then
124 comps=$(compgen -A hostname)
127 comps=$( __get_machines )
129 --identity|--image-path|--avatar|--login-background)
130 comps=$(compgen -A file -- "$cur" )
134 comps='pretty short off'
137 comps='full stripped minimal'
139 --locked|--enforce-password-policy|--password-change-now|--luks-discard|--luks-offline-discard|--nosuid|--nodev|--noexec|--kill-processes|--auto-login)
142 -d|--home-dir|--skel|-b|--blob)
143 comps=$(compgen -A directory -- "$cur" )
147 comps=$(compgen -A group -- "$cur" )
150 comps=$(cat /etc/shells)
153 comps='btrfs ext4 xfs'
156 comps=$(compgen -A user -- "$cur" )
159 comps=$(localectl list-locales 2>/dev/null)
162 comps=$(find /usr/share/{x,wayland-}sessions/ -type f -name '*.desktop' -exec basename {} .desktop \; 2>/dev/null | sort -u)
165 comps='wayland x11 tty'
168 COMPREPLY=( $(compgen -W '$comps' -- "$cur") )
172 if [[ "$cur" = -* ]]; then
173 COMPREPLY=( $(compgen -W '${OPTS[*]}' -- "$cur") )
178 [STANDALONE]='list lock-all register unregister adopt'
180 [NAMES]='activate deactivate inspect authenticate remove lock unlock'
181 [NAME]='update passwd'
186 for ((i=0; i < COMP_CWORD; i++)); do
187 if __contains_word "${COMP_WORDS[i]}" ${VERBS[*]}; then
188 verb=${COMP_WORDS[i]}
193 if [[ -z ${verb-} ]]; then
195 elif __contains_word "$verb" ${VERBS[NAME]}; then
197 elif __contains_word "$verb" ${VERBS[NAMES]}; then
199 elif __contains_word "$verb" ${VERBS[STANDALONE]} ${VERBS[CREATE]} ${VERBS[RESIZE]}; then
201 elif __contains_word "$verb" ${VERBS[WITH]}; then
205 COMPREPLY=( $(compgen -W '$comps' -- "$cur") )
209 complete -F _homectl homectl