_loginctl revision 799d54be0b681c0329539fca604261994e7f8c0e
d657c51f14601d0235434ffb78cf6ac0f27cc83cLennart Poettering#compdef loginctl
31cee6f634ce07aa2c3514a506f93830f91f14a5Lennart Poettering_hosts_or_user_at_host() {
31cee6f634ce07aa2c3514a506f93830f91f14a5Lennart Poettering _alternative \
31cee6f634ce07aa2c3514a506f93830f91f14a5Lennart Poettering 'users-hosts:: _user_at_host' \
31cee6f634ce07aa2c3514a506f93830f91f14a5Lennart Poettering 'hosts:: _hosts'
31cee6f634ce07aa2c3514a506f93830f91f14a5Lennart Poettering_loginctl_all_sessions(){_sys_all_sessions=($(loginctl list-sessions | { while read a b; do echo " $a"; done; }) )}
9fa2f41077b2d76685058836f602f38715b5eef3Kay Sievers_loginctl_all_users() {_sys_all_users=( $(loginctl list-users | { while read a b; do echo " $a"; done; }) )}
9fa2f41077b2d76685058836f602f38715b5eef3Kay Sievers_loginctl_all_seats() {_sys_all_seats=( $(loginctl list-seats | { while read a b; do echo " $a"; done; }) )}
31cee6f634ce07aa2c3514a506f93830f91f14a5Lennart Poettering# Completion functions for SESSIONS
9fa2f41077b2d76685058836f602f38715b5eef3Kay Sieversfor fun in session-status show-session activate lock-session unlock-session terminate-session kill-session ; do
31cee6f634ce07aa2c3514a506f93830f91f14a5Lennart Poettering (( $+functions[_loginctl_$fun] )) || _loginctl_$fun()
31cee6f634ce07aa2c3514a506f93830f91f14a5Lennart Poettering _loginctl_all_sessions
31cee6f634ce07aa2c3514a506f93830f91f14a5Lennart Poettering compadd "$@" -a - _sys_all_sessions
31cee6f634ce07aa2c3514a506f93830f91f14a5Lennart Poettering# Completion functions for USERS
31cee6f634ce07aa2c3514a506f93830f91f14a5Lennart Poetteringfor fun in user-status show-user enable-linger disable-linger terminate-user kill-user ; do
31cee6f634ce07aa2c3514a506f93830f91f14a5Lennart Poettering (( $+functions[_loginctl_$fun] )) || _loginctl_$fun()
31cee6f634ce07aa2c3514a506f93830f91f14a5Lennart Poettering _loginctl_all_users
5430f7f2bc7330f3088b894166bf3524a067e3d8Lennart Poettering compadd "$@" -a - _sys_all_users
673eab9bf0d2d79a72f3d7c430807b8786de7ee3Lennart Poettering# Completion functions for SEATS
5430f7f2bc7330f3088b894166bf3524a067e3d8Lennart Poettering(( $+functions[_loginctl_seats] )) || _loginctl_seats()
f28cbd0382ca53baa99803bbc907a469fbf68128Kay Sievers _loginctl_all_seats
673eab9bf0d2d79a72f3d7c430807b8786de7ee3Lennart Poettering compadd "$@" -a - _sys_all_seats
b7f44df59a7f76d2bd5302df2f5ec9be9b7fa2faLennart Poetteringfor fun in seat-status show-seat terminate-seat ; do
713bc0cfa477ca1df8769041cb3dbc83c10eace2Kay Sievers (( $+functions[_loginctl_$fun] )) || _loginctl_$fun()
713bc0cfa477ca1df8769041cb3dbc83c10eace2Kay Sievers { _loginctl_seats }
713bc0cfa477ca1df8769041cb3dbc83c10eace2Kay Sievers# Completion functions for ATTACH
713bc0cfa477ca1df8769041cb3dbc83c10eace2Kay Sievers(( $+functions[_loginctl_attach] )) || _loginctl_attach()
713bc0cfa477ca1df8769041cb3dbc83c10eace2Kay Sievers _loginctl_all_seats
ffbd2c4d45787ba5ba85a32db6551efba66a1ee6Nathaniel Chen _arguments -w -C -S -s \
ffbd2c4d45787ba5ba85a32db6551efba66a1ee6Nathaniel Chen ':seat:_loginctl_seats' \
713bc0cfa477ca1df8769041cb3dbc83c10eace2Kay Sievers '*:device:_files'
713bc0cfa477ca1df8769041cb3dbc83c10eace2Kay Sievers# no loginctl completion for:
713bc0cfa477ca1df8769041cb3dbc83c10eace2Kay Sievers# [STANDALONE]='list-sessions list-users list-seats flush-devices'
713bc0cfa477ca1df8769041cb3dbc83c10eace2Kay Sievers(( $+functions[_loginctl_command] )) || _loginctl_command()
713bc0cfa477ca1df8769041cb3dbc83c10eace2Kay Sievers local -a _loginctl_cmds
713bc0cfa477ca1df8769041cb3dbc83c10eace2Kay Sievers _loginctl_cmds=(
713bc0cfa477ca1df8769041cb3dbc83c10eace2Kay Sievers "list-sessions:List sessions"
713bc0cfa477ca1df8769041cb3dbc83c10eace2Kay Sievers "session-status:Show session status"
713bc0cfa477ca1df8769041cb3dbc83c10eace2Kay Sievers "show-session:Show properties of one or more sessions"
713bc0cfa477ca1df8769041cb3dbc83c10eace2Kay Sievers "activate:Activate a session"
713bc0cfa477ca1df8769041cb3dbc83c10eace2Kay Sievers "lock-session:Screen lock one or more sessions"
713bc0cfa477ca1df8769041cb3dbc83c10eace2Kay Sievers "unlock-session:Screen unlock one or more sessions"
713bc0cfa477ca1df8769041cb3dbc83c10eace2Kay Sievers "terminate-session:Terminate one or more sessions"
713bc0cfa477ca1df8769041cb3dbc83c10eace2Kay Sievers "kill-session:Send signal to processes of a session"
713bc0cfa477ca1df8769041cb3dbc83c10eace2Kay Sievers "list-users:List users"
713bc0cfa477ca1df8769041cb3dbc83c10eace2Kay Sievers "user-status:Show user status"
713bc0cfa477ca1df8769041cb3dbc83c10eace2Kay Sievers "show-user:Show properties of one or more users"
f28cbd0382ca53baa99803bbc907a469fbf68128Kay Sievers "enable-linger:Enable linger state of one or more users"
713bc0cfa477ca1df8769041cb3dbc83c10eace2Kay Sievers "disable-linger:Disable linger state of one or more users"
713bc0cfa477ca1df8769041cb3dbc83c10eace2Kay Sievers "terminate-user:Terminate all sessions of one or more users"
713bc0cfa477ca1df8769041cb3dbc83c10eace2Kay Sievers "kill-user:Send signal to processes of a user"
713bc0cfa477ca1df8769041cb3dbc83c10eace2Kay Sievers "list-seats:List seats"
713bc0cfa477ca1df8769041cb3dbc83c10eace2Kay Sievers "seat-status:Show seat status"
713bc0cfa477ca1df8769041cb3dbc83c10eace2Kay Sievers "show-seat:Show properties of one or more seats"
713bc0cfa477ca1df8769041cb3dbc83c10eace2Kay Sievers "attach:Attach one or more devices to a seat"
f28cbd0382ca53baa99803bbc907a469fbf68128Kay Sievers "flush-devices:Flush all device associations"
f28cbd0382ca53baa99803bbc907a469fbf68128Kay Sievers "terminate-seat:Terminate all sessions on one or more seats"
77b6e19458f37cfde127ec6aa9494c0ac45ad890Lennart Poettering if (( CURRENT == 1 )); then
77b6e19458f37cfde127ec6aa9494c0ac45ad890Lennart Poettering _describe -t commands 'loginctl command' _loginctl_cmds || compadd "$@"
77b6e19458f37cfde127ec6aa9494c0ac45ad890Lennart Poettering local curcontext="$curcontext"
77b6e19458f37cfde127ec6aa9494c0ac45ad890Lennart Poettering cmd="${${_loginctl_cmds[(r)$words[1]:*]%%:*}}"
c1c8ca815bb1ef040c0a84cccd51282e4ce8f4deKay Sievers if (( $#cmd )); then
3ede835a0486f2ecc025dede0b33e9a1edc06d30Lennart Poettering curcontext="${curcontext%:*:*}:loginctl-${cmd}:"
f4f8f7b546508e1e7c94b072df685ac1342e8d7eMichael Biebl _call_function ret _loginctl_$cmd || _message 'no more arguments'
3ede835a0486f2ecc025dede0b33e9a1edc06d30Lennart Poettering _message "unknown loginctl command: $words[1]"
7b17a7d72f5ba5ad838b19803534c56a46f3bce9Lennart Poettering_arguments -s \
7b17a7d72f5ba5ad838b19803534c56a46f3bce9Lennart Poettering {-h,--help}'[Show help]' \
7b17a7d72f5ba5ad838b19803534c56a46f3bce9Lennart Poettering '--version[Show package version]' \
2cc86f094a8c316f7feb0336df3827a3264b116dZbigniew Jędrzejewski-Szmek \*{-p,--property=}'[Show only properties by this name]:unit property' \
2cc86f094a8c316f7feb0336df3827a3264b116dZbigniew Jędrzejewski-Szmek {-a,--all}'[Show all properties, including empty ones]' \
2cc86f094a8c316f7feb0336df3827a3264b116dZbigniew Jędrzejewski-Szmek '--kill-who=[Who to send signal to]:killwho:(main control all)' \
2cc86f094a8c316f7feb0336df3827a3264b116dZbigniew Jędrzejewski-Szmek {-s,--signal=}'[Which signal to send]:signal:_signals' \
2cc86f094a8c316f7feb0336df3827a3264b116dZbigniew Jędrzejewski-Szmek '--no-ask-password[Do not ask for system passwords]' \
c3d2d86d4f40593a361e33b101f5384a8ea2cdb7Tom Gundersen {-H,--host=}'[Show information for remote host]:userathost:_hosts_or_user_at_host' \
c3d2d86d4f40593a361e33b101f5384a8ea2cdb7Tom Gundersen {-P,--privileged}'[Acquire privileges before execution]' \
2cc86f094a8c316f7feb0336df3827a3264b116dZbigniew Jędrzejewski-Szmek '--no-pager[Do not pipe output into a pager]' \
46ba8aae2b82bc5c87ba347e6bf914ecd5e9d51eLennart Poettering '*::loginctl command:_loginctl_command'