3 _loginctl_all_sessions() {
4 local session description
5 loginctl --no-legend list-sessions | while read -r session description; do
6 _sys_all_sessions+=( "$session" )
7 _sys_all_sessions_descr+=( "${session}:$description" )
11 _loginctl_all_users() {
13 loginctl --no-legend list-users | while read -r uid description; do
14 _sys_all_users+=( "$uid" )
15 _sys_all_users_descr+=( "${uid}:$description" )
19 _loginctl_all_seats() {
20 local seat description
21 loginctl --no-legend list-seats | while read -r seat description; do
22 _sys_all_seats+=( "$seat" )
23 _sys_all_seats_descr+=( "${seat}:$description" )
28 # Completion functions for SESSIONS
29 for fun in session-status show-session activate lock-session unlock-session terminate-session kill-session ; do
30 (( $+functions[_loginctl_$fun] )) || _loginctl_$fun()
32 local -a _sys_all_sessions{,_descr}
34 _loginctl_all_sessions
35 for _ignore in $words[2,-1]; do
36 _sys_all_sessions[(i)$_ignore]=()
37 _sys_all_sessions_descr[(i)$_ignore:*]=()
40 _describe -t systemd-sessions session _sys_all_sessions_descr _sys_all_sessions "$@"
44 # Completion functions for USERS
45 for fun in user-status show-user enable-linger disable-linger terminate-user kill-user ; do
46 (( $+functions[_loginctl_$fun] )) || _loginctl_$fun()
48 local -a _sys_all_users{,_descr}
49 zstyle -a ":completion:${curcontext}:users" users _sys_all_users
51 if ! (( $#_sys_all_users )); then
55 for _ignore in $words[2,-1]; do
56 _sys_all_users[(i)$_ignore]=()
57 _sys_all_users_descr[(i)$_ignore:*]=()
59 # using the common tag `users' here, not rolling our own `systemd-users' tag
60 _describe -t users user ${_sys_all_users_descr:+_sys_all_users_descr} _sys_all_users "$@"
64 # Completion functions for SEATS
65 (( $+functions[_loginctl_seats] )) || _loginctl_seats()
67 local -a _sys_all_seats{,_descr}
70 for _ignore in $words[2,-1]; do
71 _sys_all_seats[(i)$_ignore]=()
72 _sys_all_seats_descr[(i)$_ignore:*]=()
75 _describe -t systemd-seats seat _sys_all_seats_descr _sys_all_seats "$@"
77 for fun in seat-status show-seat terminate-seat ; do
78 (( $+functions[_loginctl_$fun] )) || _loginctl_$fun()
82 # Completion functions for ATTACH
83 (( $+functions[_loginctl_attach] )) || _loginctl_attach()
85 _arguments -w -C -S -s \
86 ':seat:_loginctl_seats' \
90 # no loginctl completion for:
91 # [STANDALONE]='list-sessions list-users list-seats flush-devices'
93 (( $+functions[_loginctl_command] )) || _loginctl_command()
95 local -a _loginctl_cmds
97 "list-sessions:List sessions"
98 "session-status:Show session status"
99 "show-session:Show properties of one or more sessions"
100 "activate:Activate a session"
101 "lock-session:Screen lock one or more sessions"
102 "unlock-session:Screen unlock one or more sessions"
103 "lock-sessions:Screen lock all current sessions"
104 "unlock-sessions:Screen unlock all current sessions"
105 "terminate-session:Terminate one or more sessions"
106 "kill-session:Send signal to processes of a session"
107 "list-users:List users"
108 "user-status:Show user status"
109 "show-user:Show properties of one or more users"
110 "enable-linger:Enable linger state of one or more users"
111 "disable-linger:Disable linger state of one or more users"
112 "terminate-user:Terminate all sessions of one or more users"
113 "kill-user:Send signal to processes of a user"
114 "list-seats:List seats"
115 "seat-status:Show seat status"
116 "show-seat:Show properties of one or more seats"
117 "attach:Attach one or more devices to a seat"
118 "flush-devices:Flush all device associations"
119 "terminate-seat:Terminate all sessions on one or more seats"
122 if (( CURRENT == 1 )); then
123 _describe -t commands 'loginctl command' _loginctl_cmds || compadd "$@"
125 local curcontext="$curcontext" _ignore
127 cmd="${${_loginctl_cmds[(r)$words[1]:*]%%:*}}"
130 curcontext="${curcontext%:*:*}:loginctl-${cmd}:"
132 _call_function ret _loginctl_$cmd || _message 'no more arguments'
134 _message "unknown loginctl command: $words[1]"
142 {-h,--help}'[Show help]' \
143 '--version[Show package version]' \
144 \*{-p+,--property=}'[Show only properties by this name]:unit property' \
145 {-a,--all}'[Show all properties, including empty ones]' \
146 '--kill-who=[Who to send signal to]:killwho:(main control all)' \
147 {-s+,--signal=}'[Which signal to send]:signal:_signals' \
148 {-H+,--host=}'[Operate on remote host]:userathost:_sd_hosts_or_user_at_host' \
149 {-M+,--machine=}'[Operate on local container]:machine:_sd_machines' \
150 {-l,--full}'[Do not ellipsize output]' \
151 '--no-pager[Do not pipe output into a pager]' \
152 '--no-legend[Do not show the headers and footers]' \
153 '--no-ask-password[Do not ask for system passwords]' \
154 {-n+,--lines=}'[Number of journal entries to show]' \
155 {-o+,--output=}'[Change journal output mode]:output modes:_sd_outputmodes' \
156 '*::loginctl command:_loginctl_command'