f686d7
#compdef systemctl loginctl journalctl hostnamectl localectl timedatectl systemd-coredumpctl udevadm systemd-analyze systemd-cat systemd-ask-password systemd-cgls systemd-cgtop systemd-delta systemd-detect-virt systemd-inhibit systemd-machine-id-setup systemd-notify systemd-nspawn systemd-tmpfiles systemd-tty-ask-password-agent machinectl
f686d7
f686d7
_ctls()
f686d7
{
f686d7
    local curcontext="$curcontext" state lstate line
f686d7
    case "$service" in
f686d7
        systemctl)
f686d7
            # -s for aggregated options like -aP
f686d7
            _arguments -s \
f686d7
                {-h,--help}'[Show help]' \
f686d7
                '--version[Show package version]' \
f686d7
                {-t,--type=}'[List only units of a particular type]:unit type:(automount device mount path service snapshot socket swap target timer)' \
f686d7
                \*{-p,--property=}'[Show only properties by specific name]:unit property' \
f686d7
                {-a,--all}'[Show all units/properties, including dead/empty ones]' \
f686d7
                '--reverse[Show reverse dependencies]' \
f686d7
                '--after[Show units ordered after]' \
f686d7
                '--before[Show units ordered before]' \
f686d7
                '--failed[Show only failed units]' \
f686d7
                {-l,--full}"[Don't ellipsize unit names on output]" \
f686d7
                '--fail[When queueing a new job, fail if conflicting jobs are pending]' \
f686d7
                '--ignore-dependencies[When queueing a new job, ignore all its dependencies]' \
f686d7
                '--kill-who=[Who to send signal to]:killwho:(main control all)' \
f686d7
                {-s,--signal=}'[Which signal to send]:signal:_signals' \
f686d7
                {-H,--host=}'[Show information for remote host]:userathost:_hosts_or_user_at_host' \
f686d7
                {-P,--privileged}'[Acquire privileges before execution]' \
f686d7
                {-q,--quiet}'[Suppress output]' \
f686d7
                '--no-block[Do not wait until operation finished]' \
f686d7
                "--no-wall[Don't send wall message before halt/power-off/reboot]" \
f686d7
                "--no-reload[When enabling/disabling unit files, don't reload daemon configuration]" \
f686d7
                '--no-legend[Do not print a legend, i.e. the column headers and the footer with hints]' \
f686d7
                '--no-pager[Do not pipe output into a pager]' \
f686d7
                '--no-ask-password[Do not ask for system passwords]' \
f686d7
                '--system[Connect to system manager]' \
f686d7
                '--user[Connect to user service manager]' \
f686d7
                '--global[Enable/disable unit files globally]' \
f686d7
                {-f,--force}'[When enabling unit files, override existing symlinks. When shutting down, execute action immediately]' \
f686d7
                '--root=[Enable unit files in the specified root directory]:directory:_directories' \
f686d7
                '--runtime[Enable unit files only temporarily until next reboot]' \
f686d7
                {-n,--lines=}'[Journal entries to show]:number of entries' \
f686d7
                {-o,--output=}'[Change journal output mode]:modes:_outputmodes' \
f686d7
                '*::systemctl command:_systemctl_command'
f686d7
        ;;
f686d7
        loginctl)
f686d7
            _arguments -s \
f686d7
                {-h,--help}'[Show help]' \
f686d7
                '--version[Show package version]' \
f686d7
                \*{-p,--property=}'[Show only properties by this name]:unit property' \
f686d7
                {-a,--all}'[Show all properties, including empty ones]' \
f686d7
                '--kill-who=[Who to send signal to]:killwho:(main control all)' \
f686d7
                {-s,--signal=}'[Which signal to send]:signal:_signals' \
f686d7
                '--no-ask-password[Do not ask for system passwords]' \
f686d7
                {-H,--host=}'[Show information for remote host]:userathost:_hosts_or_user_at_host' \
f686d7
                {-P,--privileged}'[Acquire privileges before execution]' \
f686d7
                '--no-pager[Do not pipe output into a pager]' \
f686d7
                '*::loginctl command:_loginctl_command'
f686d7
        ;;
f686d7
f686d7
        hostnamectl)
f686d7
            _arguments -s \
f686d7
                {-h,--help}'[Show this help]' \
f686d7
                '--version[Show package version]' \
f686d7
                '--transient[Only set transient hostname]' \
f686d7
                '--static[Only set static hostname]' \
f686d7
                '--pretty[Only set pretty hostname]' \
f686d7
                '--no-ask-password[Do not prompt for password]' \
f686d7
                {-H,--host=}'[Operate on remote host]:userathost:_hosts_or_user_at_host' \
f686d7
                '*::hostnamectl commands:_hostnamectl_command'
f686d7
        ;;
f686d7
        journalctl)
f686d7
            _arguments -s \
f686d7
                '--since=[Start showing entries newer or of the specified date]:YYYY-MM-DD HH\:MM\:SS' \
f686d7
                '--until=[Stop showing entries older or of the specified date]:YYYY-MM-DD HH\:MM\:SS' \
f686d7
                {-c,--cursor=}'[Start showing entries from specified cursor]:cursors:_journal_fields __CURSORS' \
f686d7
                '--system[Show system and kernel messages]' \
f686d7
                '--user[Show messages from user services]' \
f686d7
                {-b,--this-boot}'[Show data only from current boot]' \
f686d7
                {-u,--unit=}'[Show data only from the specified unit]:units:_journal_fields _SYSTEMD_UNIT' \
f686d7
                '--user-unit[Show data only from the specified user session unit]:units:_journal_fields _SYSTEMD_USER_UNIT' \
f686d7
                {-p,--priority=}'[Show only messages within the specified priority range]:priority:_journal_fields PRIORITY' \
f686d7
                {-f,--follow}'[Follow journal]' \
f686d7
                {-n,--lines=}'[Number of journal entries to show]:integer' \
f686d7
                '--no-tail[Show all lines, even in follow mode]' \
f686d7
                {-o,--output=}'[Change journal output mode]:output modes:_outputmodes' \
f686d7
                {-l,--full}'[Show long fields in full]' \
f686d7
                {-a,--all}'[Show all fields, including long and unprintable]' \
f686d7
                {-q,--quiet}"[Don't show privilege warning]" \
f686d7
                '--no-pager[Do not pipe output into a pager]' \
f686d7
                {-m,--merge}'[Show entries from all available journals]' \
f686d7
                {-D,--directory=}'[Show journal files from directory]:directories:_directories' \
f686d7
                '--interval=[Time interval for changing the FSS sealing key]:time interval' \
f686d7
                '--verify-key=[Specify FSS verification key]:FSS key' \
f686d7
                {-h,--help}'[Show this help]' \
f686d7
                '--version[Show package version]' \
f686d7
                '--new-id128[Generate a new 128 Bit ID]' \
f686d7
                '--header[Show journal header information]' \
f686d7
                '--disk-usage[Show total disk usage]' \
f686d7
                {-F,--field=}'[List all values a certain field takes]:Fields:_list_fields' \
f686d7
                '--setup-keys[Generate new FSS key pair]' \
f686d7
                '--verify[Verify journal file consistency]' \
f686d7
                '--list-catalog[List messages in catalog]' \
f686d7
                '--update-catalog[Update binary catalog database]' \
f686d7
                '*::default: _journal_none'
f686d7
        ;;
f686d7
        localectl)
f686d7
            _arguments \
f686d7
                {-h,--help}'[Show this help]' \
f686d7
                '--version[Show package version]' \
f686d7
                "--no-convert[Don't convert keyboard mappings]" \
f686d7
                '--no-pager[Do not pipe output into a pager]' \
f686d7
                '--no-ask-password[Do not prompt for password]' \
f686d7
                {-H,--host=}'[Operate on remote host]:userathost:_hosts_or_user_at_host' \
f686d7
                '*::localectl commands:_localectl_command'
f686d7
        ;;
f686d7
        systemd-coredumpctl)
f686d7
            _arguments \
f686d7
                {-o,--output=}'[Write output to FILE]:output file:_files' \
f686d7
                '--no-pager[Do not pipe output into a pager]' \
f686d7
                {-h,--help}'[Show this help]' \
f686d7
                '--version[Show package version]' \
f686d7
                '*::systemd-coredumpctl commands:_systemd-coredumpctl_command'
f686d7
f686d7
        ;;
f686d7
        timedatectl)
f686d7
            _arguments -s \
f686d7
                {-h,--help}'[Show this help]' \
f686d7
                '--version[Show package version]' \
f686d7
                '--adjust-system-clock[Adjust system clock when changing local RTC mode]' \
f686d7
                '--no-pager[Do not pipe output into a pager]' \
f686d7
                '--no-ask-password[Do not prompt for password]' \
f686d7
                {-H,--host=}'[Operate on remote host]:userathost:_hosts_or_user_at_host' \
f686d7
                '*::timedatectl commands:_timedatectl_command'
f686d7
        ;;
f686d7
        udevadm)
f686d7
            _arguments \
f686d7
                '--debug[Print debug messages to stderr]' \
f686d7
                '--version[Print version number]' \
f686d7
                '--help[Print help text]' \
f686d7
                '*::udevadm commands:_udevadm_command'
f686d7
        ;;
f686d7
        systemd-analyze)
f686d7
            _arguments \
f686d7
                {-h,--help}'[Show help text.]' \
f686d7
                '--user[Shows performance data of user sessions instead of the system manager.]' \
f686d7
                '--order[When generating graph for dot, show only order]' \
f686d7
                '--require[When generating graph for dot, show only requirement]' \
f686d7
                '*::systemd-analyze commands:_systemd_analyze_command'
f686d7
        ;;
f686d7
        systemd-ask-password)
f686d7
            _arguments \
f686d7
                {-h,--help}'[Show this help]' \
f686d7
                '--icon=[Icon name]' \
f686d7
                '--timeout=[Timeout in sec]' \
f686d7
                '--no-tty[Ask question via agent even on TTY]' \
f686d7
                '--accept-cached[Accept cached passwords]' \
f686d7
                '--multiple[List multiple passwords if available]'
f686d7
        ;;
f686d7
        systemd-cat)
f686d7
            _arguments \
f686d7
                {-h,--help}'[Show this help]' \
f686d7
                '--version[Show package version.]' \
f686d7
                {-t,--identifier=}'[Set syslog identifier.]' \
f686d7
                {-p,--priority=}'[Set priority value.]:value:({0..7})' \
f686d7
                '--level-prefix=[Control whether level prefix shall be parsed.]:boolean:(1 0)' \
f686d7
                ':Message'
f686d7
        ;;
f686d7
        systemd-cgls)
f686d7
            _arguments \
f686d7
                {-h,--help}'[Show this help]' \
f686d7
                '--version[Show package version]' \
f686d7
                '--no-pager[Do not pipe output into a pager]' \
f686d7
                {-a,--all}'[Show all groups, including empty]' \
f686d7
                '-k[Include kernel threads in output]' \
f686d7
                ':cgroups:(cpuset cpu cpuacct memory devices freezer net_cls blkio)'
f686d7
        ;;
f686d7
        systemd-cgtop)
f686d7
            _arguments \
f686d7
                {-h,--help}'[Show this help]' \
f686d7
                '--version[Print version and exit]' \
f686d7
                '(-c -m -i -t)-p[Order by path]' \
f686d7
                '(-c -p -m -i)-t[Order by number of tasks]' \
f686d7
                '(-m -p -i -t)-c[Order by CPU load]' \
f686d7
                '(-c -p -i -t)-m[Order by memory load]' \
f686d7
                '(-c -m -p -t)-i[Order by IO load]' \
f686d7
                {-d,--delay=}'[Specify delay]' \
f686d7
                {-n,--iterations=}'[Run for N iterations before exiting]' \
f686d7
                {-b,--batch}'[Run in batch mode, accepting no input]' \
f686d7
                '--depth=[Maximum traversal depth]'
f686d7
        ;;
f686d7
        systemd-delta)
f686d7
            _arguments \
f686d7
                {-h,--help}'[Show this help]' \
f686d7
                '--version[Show package version]' \
f686d7
                '--no-pager[Do not pipe output into a pager]' \
f686d7
                '--diff=[Show a diff when overridden files differ]:boolean:(1 0)' \
f686d7
                {-t,--type=}'[Only display a selected set of override types]:types:(masked equivalent redirected overridden unchanged)' \
f686d7
                ':SUFFIX:(tmpfiles.d sysctl.d systemd/system)'
f686d7
        ;;
f686d7
        systemd-detect-virt)
f686d7
            _arguments \
f686d7
                {-h,--help}'[Show this help]' \
f686d7
                '--version[Show package version]' \
f686d7
                {-c,--container}'[Only detect whether we are run in a container]' \
f686d7
                {-v,--vm}'[Only detect whether we are run in a VM]' \
f686d7
                {-q,--quiet}"[Don't output anything, just set return value]"
f686d7
        ;;
f686d7
        systemd-inhibit)
f686d7
            _arguments \
f686d7
                {-h,--help}'[Show this help]' \
f686d7
                '--version[Show package version]' \
f686d7
                '--what=[Operations to inhibit]:options:(shutdown sleep idle handle-power-key handle-suspend-key handle-hibernate-key handle-lid-switch)' \
f686d7
                '--who=[A descriptive string who is inhibiting]' \
f686d7
                '--why=[A descriptive string why is being inhibited]' \
f686d7
                '--mode=[One of block or delay]' \
f686d7
                '--list[List active inhibitors]' \
f686d7
                '*:commands:_systemd_inhibit_command'
f686d7
        ;;
f686d7
        systemd-machine-id-setup)
f686d7
            _arguments \
f686d7
                {-h,--help}'[Show this help]' \
f686d7
                '--version[Show package version]'
f686d7
        ;;
f686d7
        systemd-notify)
f686d7
            _arguments \
f686d7
                {-h,--help}'[Show this help]' \
f686d7
                '--version[Show package version]' \
f686d7
                '--ready[Inform the init system about service start-up completion.]' \
f686d7
                '--pid=[Inform the init system about the main PID of the daemon]' \
f686d7
                '--status=[Send a free-form status string for the daemon to the init systemd]' \
f686d7
                '--booted[Returns 0 if the system was booted up with systemd]' \
f686d7
                '--readahead=[Controls disk read-ahead operations]:arguments:(cancel done noreply)'
f686d7
        ;;
f686d7
        systemd-nspawn)
f686d7
            _arguments \
f686d7
                {-h,--help}'[Show this help]' \
f686d7
                {--directory=,-D}'[Directory to use as file system root for the namespace container. If omitted the current directory will be used.]:directories:_directories' \
f686d7
                {--boot,-b}'[Automatically search for an init binary and invoke it instead of a shell or a user supplied program.]' \
f686d7
                {--user=,-u}'[Run the command under specified user, create home directory and cd into it.]' \
f686d7
                '--uuid=[Set the specified uuid for the container.]' \
f686d7
                {--controllers=,-C}'[Makes the container appear in other hierarchies than the name=systemd:/ one. Takes a comma-separated list of controllers.]' \
f686d7
                '--private-network[Turn off networking in the container. This makes all network interfaces unavailable in the container, with the exception of the loopback device.]' \
f686d7
                '--read-only[Mount the root file system read only for the container.]' \
f686d7
                '--capability=[List one or more additional capabilities to grant the container.]:capabilities:_systemd-nspawn' \
f686d7
                "--link-journal=[Control whether the container's journal shall be made visible to the host system.]:options:(no, host, guest, auto)" \
f686d7
                '-j[Equivalent to --link-journal=guest.]'
f686d7
        ;;
f686d7
        systemd-tmpfiles)
f686d7
            _arguments \
f686d7
                '--create[Create, set ownership/permissions based on the config files.]' \
f686d7
                '--clean[Clean up all files and directories with an age parameter configured.]' \
f686d7
                '--remove[All files and directories marked with r, R in the configuration files are removed.]' \
f686d7
                '--prefix=[Only apply rules that apply to paths with the specified prefix.]' \
f686d7
                '--exclude-prefix=[Ignore rules that apply to paths with the specified prefix.]' \
f686d7
                '--help[Prints a short help text and exits.]' \
f686d7
                '*::files:_files'
f686d7
        ;;
f686d7
        systemd-tty-ask-password-agent)
f686d7
            _arguments \
f686d7
                {-h,--help}'[Prints a short help text and exits.]' \
f686d7
                '--version[Prints a short version string and exits.]' \
f686d7
                '--list[Lists all currently pending system password requests.]' \
f686d7
                '--query[Process all currently pending system password requests by querying the user on the calling TTY.]' \
f686d7
                '--watch[Continuously process password requests.]' \
f686d7
                '--wall[Forward password requests to wall(1).]' \
f686d7
                '--plymouth[Ask question with plymouth(8).]' \
f686d7
                '--console[Ask question on /dev/console.]'
f686d7
        ;;
f686d7
        machinectl)
f686d7
            _arguments \
f686d7
                {-h,--help}'[Prints a short help text and exits.]' \
f686d7
                '--version[Prints a short version string and exits.]' \
f686d7
                {-p,--property=}'[Limit output to specified property.]:property:(Name Id Timestamp TimestampMonotonic Service Scope Leader Class State RootDirectory)' \
f686d7
                {-a,--all}'[Show all proerties]' \
f686d7
                (-l,--full)'[Do not ellipsize cgroup members]' \
f686d7
                '--no-pager[Do not pipe output into a pager]' \
f686d7
                '--no-ask-password[Do not ask for system passwords]' \
f686d7
                '--kill-who=[Who to send signal to]:killwho:(leader all)' \
f686d7
                {-s,--signal=}'[Which signal to send]:signal:_signals' \
f686d7
                {-H,--host=}'[Show information for remote host]:userathost:_hosts_or_user_at_host' \
f686d7
                {-P,--privileged}'[Acquire privileges before execution]' \
f686d7
                '*::machinectl command:_machinectl_command'
f686d7
        ;;
f686d7
        *) _message 'eh?' ;;
f686d7
    esac
f686d7
}
f686d7
f686d7
_systemd-nspawn(){
f686d7
    local -a _caps
f686d7
    _caps=( CAP_CHOWN CAP_DAC_OVERRIDE CAP_DAC_READ_SEARCH
f686d7
            CAP_FOWNER CAP_FSETID CAP_IPC_OWNER CAP_KILL CAP_LEASE CAP_LINUX_IMMUTABLE
f686d7
            CAP_NET_BIND_SERVICE CAP_NET_BROADCAST CAP_NET_RAW CAP_SETGID CAP_SETFCAP CAP_SETPCAP
f686d7
            CAP_SETUID CAP_SYS_ADMIN CAP_SYS_CHROOT CAP_SYS_NICE CAP_SYS_PTRACE CAP_SYS_TTY_CONFIG
f686d7
            CAP_SYS_RESOURCE CAP_SYS_BOOT )
f686d7
    _values -s , 'capabilities' "$_caps[@]"
f686d7
}
f686d7
f686d7
_systemd_inhibit_command(){
f686d7
    if (( CURRENT == 1 )); then
f686d7
        compset -q
f686d7
        _normal
f686d7
    else
f686d7
        local n=${words[(b:2:i)[^-]*]}
f686d7
        if (( n <= CURRENT )); then
f686d7
            compset -n $n
f686d7
            _alternative \
f686d7
                'files:file:_files' \
f686d7
                'commands:command:_normal' && return 0
f686d7
        fi
f686d7
        _default
f686d7
    fi
f686d7
f686d7
}
f686d7
f686d7
_systemd_analyze_command(){
f686d7
    local -a _systemd_analyze_cmds
f686d7
    # Descriptions taken from systemd-analyze --help.
f686d7
    _systemd_analyze_cmds=(
f686d7
        'time:Print time spent in the kernel before reaching userspace'
f686d7
        'blame:Print list of running units ordered by time to init'
f686d7
        'critical-chain:Print a tree of the time critical chain of units'
f686d7
        'plot:Output SVG graphic showing service initialization'
f686d7
        'dot:Dump dependency graph (in dot(1) format)'
f686d7
    )
f686d7
f686d7
    if (( CURRENT == 1 )); then
f686d7
        _describe "options" _systemd_analyze_cmds
f686d7
    else
f686d7
        _message "no more options"
f686d7
    fi
f686d7
}
f686d7
f686d7
_hosts_or_user_at_host()
f686d7
{
f686d7
  _alternative \
f686d7
    'users-hosts:: _user_at_host' \
f686d7
    'hosts:: _hosts'
f686d7
}
f686d7
f686d7
_outputmodes() {
f686d7
    local -a _output_opts
f686d7
    _output_opts=(short short-monotonic verbose export json json-pretty json-see cat)
f686d7
    _describe -t output 'output mode' _output_opts || compadd "$@"
f686d7
}
f686d7
f686d7
f686d7
(( $+functions[_systemctl_command] )) || _systemctl_command()
f686d7
{
f686d7
  local -a _systemctl_cmds
f686d7
  _systemctl_cmds=(
f686d7
    "list-units:List units"
f686d7
    "start:Start (activate) one or more units"
f686d7
    "stop:Stop (deactivate) one or more units"
f686d7
    "reload:Reload one or more units"
f686d7
    "restart:Start or restart one or more units"
f686d7
    "condrestart:Restart one or more units if active"
f686d7
    "try-restart:Restart one or more units if active"
f686d7
    "reload-or-restart:Reload one or more units if possible, otherwise start or restart"
f686d7
    "force-reload:Reload one or more units if possible, otherwise restart if active"
f686d7
    "hibernate:Hibernate the system"
f686d7
    "hybrid-sleep:Hibernate and suspend the system"
f686d7
    "reload-or-try-restart:Reload one or more units if possible, otherwise restart if active"
f686d7
    "isolate:Start one unit and stop all others"
f686d7
    "kill:Send signal to processes of a unit"
f686d7
    "is-active:Check whether units are active"
f686d7
    "is-failed:Check whether units are failed"
f686d7
    "status:Show runtime status of one or more units"
f686d7
    "show:Show properties of one or more units/jobs or the manager"
f686d7
    "reset-failed:Reset failed state for all, one, or more units"
f686d7
    "load:Load one or more units"
f686d7
    "list-unit-files:List installed unit files"
f686d7
    "enable:Enable one or more unit files"
f686d7
    "disable:Disable one or more unit files"
f686d7
    "reenable:Reenable one or more unit files"
f686d7
    "preset:Enable/disable one or more unit files based on preset configuration"
f686d7
    "help:Show documentation for specified units"
f686d7
    "list-dependencies:Show unit dependency tree"
f686d7
    "mask:Mask one or more units"
f686d7
    "unmask:Unmask one or more units"
f686d7
    "link:Link one or more units files into the search path"
f686d7
    "is-enabled:Check whether unit files are enabled"
f686d7
    "list-jobs:List jobs"
f686d7
    "cancel:Cancel all, one, or more jobs"
f686d7
    "dump:Dump server status"
f686d7
    "snapshot:Create a snapshot"
f686d7
    "delete:Remove one or more snapshots"
f686d7
    "show-environment:Dump environment"
f686d7
    "set-environment:Set one or more environment variables"
f686d7
    "unset-environment:Unset one or more environment variables"
f686d7
    "daemon-reload:Reload systemd manager configuration"
f686d7
    "daemon-reexec:Reexecute systemd manager"
f686d7
    "default:Enter system default mode"
f686d7
    "rescue:Enter system rescue mode"
f686d7
    "emergency:Enter system emergency mode"
f686d7
    "halt:Shut down and halt the system"
f686d7
    "suspend:Suspend the system"
f686d7
    "poweroff:Shut down and power-off the system"
f686d7
    "reboot:Shut down and reboot the system"
f686d7
    "kexec:Shut down and reboot the system with kexec"
f686d7
    "exit:Ask for user instance termination"
f686d7
  )
f686d7
f686d7
  if (( CURRENT == 1 )); then
f686d7
    _describe -t commands 'systemctl command' _systemctl_cmds || compadd "$@"
f686d7
  else
f686d7
    local curcontext="$curcontext"
f686d7
f686d7
    cmd="${${_systemctl_cmds[(r)$words[1]:*]%%:*}}"
f686d7
    # Deal with any aliases
f686d7
    case $cmd in
f686d7
      condrestart) cmd="try-restart";;
f686d7
      force-reload) cmd="reload-or-try-restart";;
f686d7
    esac
f686d7
f686d7
    if (( $#cmd )); then
f686d7
      curcontext="${curcontext%:*:*}:systemctl-${cmd}:"
f686d7
f686d7
      local update_policy
f686d7
      zstyle -s ":completion:${curcontext}:" cache-policy update_policy
f686d7
      if [[ -z "$update_policy" ]]; then
f686d7
        zstyle ":completion:${curcontext}:" cache-policy _systemctl_caching_policy
f686d7
      fi
f686d7
f686d7
      _call_function ret _systemctl_$cmd || _message 'no more arguments'
f686d7
    else
f686d7
      _message "unknown systemctl command: $words[1]"
f686d7
    fi
f686d7
    return ret
f686d7
  fi
f686d7
}
f686d7
f686d7
__systemctl()
f686d7
{
f686d7
  local -a _modes
f686d7
  _modes=("--user" "--system")
f686d7
  systemctl ${words:*_modes} --full --no-legend --no-pager "$@"
f686d7
}
f686d7
f686d7
f686d7
# Fills the unit list
f686d7
_systemctl_all_units()
f686d7
{
f686d7
  if ( [[ ${+_sys_all_units} -eq 0 ]] || _cache_invalid SYS_ALL_UNITS ) &&
f686d7
    ! _retrieve_cache SYS_ALL_UNITS;
f686d7
  then
f686d7
    _sys_all_units=( $(__systemctl list-units --all | { while read a b; do echo " $a"; done; }) )
f686d7
    _store_cache SYS_ALL_UNITS _sys_all_units
f686d7
  fi
f686d7
}
f686d7
f686d7
# Fills the unit list including all file units
f686d7
_systemctl_really_all_units()
f686d7
{
f686d7
  local -a all_unit_files;
f686d7
  local -a really_all_units;
f686d7
  if ( [[ ${+_sys_really_all_units} -eq 0 ]] || _cache_invalid SYS_REALLY_ALL_UNITS ) &&
f686d7
    ! _retrieve_cache SYS_REALLY_ALL_UNITS;
f686d7
  then
f686d7
    all_unit_files=( $(__systemctl list-unit-files | { while read a b; do echo " $a"; done; }) )
f686d7
    _systemctl_all_units
f686d7
    really_all_units=($_sys_all_units $all_unit_files)
f686d7
    _sys_really_all_units=(${(u)really_all_units})
f686d7
    _store_cache SYS_REALLY_ALL_UNITS _sys_really_all_units
f686d7
  fi
f686d7
}
f686d7
f686d7
_filter_units_by_property() {
f686d7
  local property=$1 value=$2 ; shift ; shift
f686d7
  local -a units ; units=($*)
f686d7
  local prop unit
f686d7
  for ((i=1; $i <= ${#units[*]}; i++)); do
f686d7
    # FIXME: "Failed to issue method call: Unknown unit" errors are ignored for
f686d7
    # now (related to DBUS_ERROR_UNKNOWN_OBJECT). in the future, we need to
f686d7
    # revert to calling 'systemctl show' once for all units, which is way
f686d7
    # faster
f686d7
    unit=${units[i]}
f686d7
    prop=${(f)"$(_call_program units "$service show --no-pager --property="$property" ${unit} 2>/dev/null")"}
f686d7
    if [[ "${prop}" = "$property=$value" ]]; then
f686d7
      echo " ${unit}"
f686d7
    fi
f686d7
  done
f686d7
}
f686d7
f686d7
_systemctl_active_units()  {_sys_active_units=(  $(__systemctl list-units          | { while read a b; do echo " $a"; done; }) )}
f686d7
_systemctl_inactive_units(){_sys_inactive_units=($(__systemctl list-units --all    | { while read a b c d; do [[ $c == "inactive" || $c == "failed" ]] && echo " $a"; done; }) )}
f686d7
_systemctl_failed_units()  {_sys_failed_units=(  $(__systemctl list-units --failed | { while read a b; do echo " $a"; done; }) )}
f686d7
_systemctl_enabled_units() {_sys_enabled_units=( $(__systemctl list-unit-files     | { while read a b; do [[ $b == "enabled" ]] && echo " $a"; done; }) )}
f686d7
_systemctl_disabled_units(){_sys_disabled_units=($(__systemctl list-unit-files     | { while read a b; do [[ $b == "disabled" ]] && echo " $a"; done; }) )}
f686d7
_systemctl_masked_units()  {_sys_masked_units=(  $(__systemctl list-unit-files     | { while read a b; do [[ $b == "masked" ]] && echo " $a"; done; }) )}
f686d7
f686d7
# Completion functions for ALL_UNITS
f686d7
for fun in is-active is-failed is-enabled status show mask preset help list-dependencies ; do
f686d7
  (( $+functions[_systemctl_$fun] )) || _systemctl_$fun()
f686d7
  {
f686d7
    _systemctl_really_all_units
f686d7
    compadd "$@" -a - _sys_really_all_units
f686d7
  }
f686d7
done
f686d7
f686d7
# Completion functions for ENABLED_UNITS
f686d7
for fun in disable reenable ; do
f686d7
  (( $+functions[_systemctl_$fun] )) || _systemctl_$fun()
f686d7
  {
f686d7
    _systemctl_enabled_units
f686d7
    _systemctl_disabled_units
f686d7
    compadd "$@" -a - _sys_enabled_units _sys_disabled_units
f686d7
  }
f686d7
done
f686d7
f686d7
# Completion functions for DISABLED_UNITS
f686d7
(( $+functions[_systemctl_enable] )) || _systemctl_enable()
f686d7
{
f686d7
  _systemctl_disabled_units
f686d7
  compadd "$@" -a - _sys_disabled_units
f686d7
}
f686d7
f686d7
# Completion functions for FAILED_UNITS
f686d7
(( $+functions[_systemctl_reset-failed] )) || _systemctl_reset-failed()
f686d7
{
f686d7
  _systemctl_failed_units
f686d7
  compadd "$@" -a - _sys_failed_units || _message "no failed unit found"
f686d7
}
f686d7
f686d7
# Completion functions for STARTABLE_UNITS
f686d7
(( $+functions[_systemctl_start] )) || _systemctl_start()
f686d7
{
f686d7
  _systemctl_inactive_units
f686d7
  compadd "$@" -a - _sys_inactive_units
f686d7
}
f686d7
f686d7
# Completion functions for STOPPABLE_UNITS
f686d7
for fun in stop kill try-restart condrestart ; do
f686d7
  (( $+functions[_systemctl_$fun] )) || _systemctl_$fun()
f686d7
  {
f686d7
    _systemctl_active_units
f686d7
    compadd "$@" - $( _filter_units_by_property CanStop yes \
f686d7
      ${_sys_active_units[*]} )
f686d7
  }
f686d7
done
f686d7
f686d7
# Completion functions for ISOLATABLE_UNITS
f686d7
(( $+functions[_systemctl_isolate] )) || _systemctl_isolate()
f686d7
{
f686d7
  _systemctl_all_units
f686d7
  compadd "$@" - $( _filter_units_by_property AllowIsolate yes \
f686d7
    ${_sys_all_units[*]} )
f686d7
}
f686d7
f686d7
# Completion functions for RELOADABLE_UNITS
f686d7
for fun in reload reload-or-try-restart force-reload ; do
f686d7
  (( $+functions[_systemctl_$fun] )) || _systemctl_$fun()
f686d7
  {
f686d7
    _systemctl_active_units
f686d7
    compadd "$@" - $( _filter_units_by_property CanReload yes \
f686d7
      ${_sys_active_units[*]} )
f686d7
  }
f686d7
done
f686d7
f686d7
# Completion functions for RESTARTABLE_UNITS
f686d7
for fun in restart reload-or-restart ; do
f686d7
  (( $+functions[_systemctl_$fun] )) || _systemctl_$fun()
f686d7
  {
f686d7
    _systemctl_all_units
f686d7
    compadd "$@" - $( _filter_units_by_property CanStart yes \
f686d7
      ${_sys_all_units[*]} | while read line; do \
f686d7
      [[ "$line" =~ \.device$ ]] || echo " $line"; \
f686d7
      done )
f686d7
  }
f686d7
done
f686d7
f686d7
# Completion functions for MASKED_UNITS
f686d7
(( $+functions[_systemctl_unmask] )) || _systemctl_unmask()
f686d7
{
f686d7
  _systemctl_masked_units
f686d7
  compadd "$@" -a - _sys_masked_units || _message "no masked unit found"
f686d7
}
f686d7
f686d7
# Completion functions for JOBS
f686d7
(( $+functions[_systemctl_cancel] )) || _systemctl_cancel()
f686d7
{
f686d7
  compadd "$@" - $(__systemctl list-jobs \
f686d7
    | cut -d' ' -f1  2>/dev/null ) || _message "no job found"
f686d7
}
f686d7
f686d7
# Completion functions for SNAPSHOTS
f686d7
(( $+functions[_systemctl_delete] )) || _systemctl_delete()
f686d7
{
f686d7
  compadd "$@" - $(__systemctl list-units --type snapshot --all \
f686d7
    | cut -d' ' -f1  2>/dev/null ) || _message "no snapshot found"
f686d7
}
f686d7
f686d7
# Completion functions for ENVS
f686d7
for fun in set-environment unset-environment ; do
f686d7
  (( $+functions[_systemctl_$fun] )) || _systemctl_$fun()
f686d7
  {
f686d7
    local fun=$0 ; fun=${fun##_systemctl_}
f686d7
    local suf
f686d7
    if [[ "${fun}" = "set-environment" ]]; then
f686d7
      suf='-S='
f686d7
    fi
f686d7
f686d7
    compadd "$@" ${suf} - $(systemctl show-environment \
f686d7
      | while read line; do echo " ${line%%\=}";done )
f686d7
  }
f686d7
done
f686d7
f686d7
(( $+functions[_systemctl_link] )) || _systemctl_link() { _files }
f686d7
f686d7
# no systemctl completion for:
f686d7
#    [STANDALONE]='daemon-reexec daemon-reload default dump
f686d7
#                  emergency exit halt kexec list-jobs list-units
f686d7
#                  list-unit-files poweroff reboot rescue show-environment'
f686d7
#         [NAME]='snapshot load'
f686d7
f686d7
_systemctl_caching_policy()
f686d7
{
f686d7
  local _sysunits
f686d7
  local -a oldcache
f686d7
f686d7
  # rebuild if cache is more than a day old
f686d7
  oldcache=( "$1"(mh+1) )
f686d7
  (( $#oldcache )) && return 0
f686d7
f686d7
  _sysunits=($(__systemctl --all | cut -d' ' -f1))
f686d7
f686d7
  if (( $#_sysunits )); then
f686d7
    for unit in $_sysunits; do
f686d7
      [[ "$unit" -nt "$1" ]] && return 0
f686d7
    done
f686d7
  fi
f686d7
f686d7
  return 1
f686d7
}
f686d7
f686d7
_list_fields() {
f686d7
    local -a journal_fields
f686d7
    journal_fields=(MESSAGE{,_ID} PRIORITY CODE_{FILE,LINE,FUNC}
f686d7
                    ERRNO SYSLOG_{FACILITY,IDENTIFIER,PID}
f686d7
                    _{P,U,G}ID _COMM _EXE _CMDLINE
f686d7
                    _AUDIT_{SESSION,LOGINUID}
f686d7
                    _SYSTEMD_{CGROUP,SESSION,UNIT,OWNER_UID}
f686d7
                    _SYSTEMD_USER_UNIT
f686d7
                    _SELINUX_CONTEXT _SOURCE_REALTIME_TIMESTAMP
f686d7
                    _{BOOT,MACHINE}_ID _HOSTNAME _TRANSPORT
f686d7
                    _KERNEL_{DEVICE,SUBSYSTEM}
f686d7
                    _UDEV_{SYSNAME,DEVNODE,DEVLINK}
f686d7
                    __CURSOR __{REALTIME,MONOTONIC}_TIMESTAMP)
f686d7
    _describe 'possible fields' journal_fields
f686d7
}
f686d7
f686d7
_journal_none() {
f686d7
    local -a _commands _files
f686d7
    _commands=( ${(f)"$(_call_program commands "$service" -F _EXE 2>/dev/null)"} )
f686d7
    _alternative : \
f686d7
        'files:/dev files:_files -W /dev -P /dev/' \
f686d7
        "commands:commands:($_commands[@])" \
f686d7
        'fields:fields:_list_fields'
f686d7
}
f686d7
f686d7
_journal_fields() {
f686d7
    local -a _fields cmd
f686d7
    cmd=("journalctl" "-F ${@[-1]}" "2>/dev/null" )
f686d7
    _fields=( ${(f)"$(_call_program fields $cmd[@])"} )
f686d7
    typeset -U _fields
f686d7
    _describe 'possible values' _fields
f686d7
}
f686d7
f686d7
f686d7
_loginctl_all_sessions(){_sys_all_sessions=($(loginctl list-sessions | { while read a b; do echo " $a"; done; }) )}
f686d7
_loginctl_all_users()   {_sys_all_users=(   $(loginctl list-users    | { while read a b; do echo " $a"; done; }) )}
f686d7
_loginctl_all_seats()   {_sys_all_seats=(   $(loginctl list-seats    | { while read a b; do echo " $a"; done; }) )}
f686d7
f686d7
# Completion functions for SESSIONS
f686d7
for fun in session-status show-session activate lock-session unlock-session terminate-session kill-session ; do
f686d7
  (( $+functions[_loginctl_$fun] )) || _loginctl_$fun()
f686d7
  {
f686d7
    _loginctl_all_sessions
f686d7
    compadd "$@" -a - _sys_all_sessions
f686d7
  }
f686d7
done
f686d7
f686d7
# Completion functions for USERS
f686d7
for fun in user-status show-user enable-linger disable-linger terminate-user kill-user ; do
f686d7
  (( $+functions[_loginctl_$fun] )) || _loginctl_$fun()
f686d7
  {
f686d7
    _loginctl_all_users
f686d7
    compadd "$@" -a - _sys_all_users
f686d7
  }
f686d7
done
f686d7
f686d7
# Completion functions for SEATS
f686d7
(( $+functions[_loginctl_seats] )) || _loginctl_seats()
f686d7
{
f686d7
  _loginctl_all_seats
f686d7
  compadd "$@" -a - _sys_all_seats
f686d7
}
f686d7
for fun in seat-status show-seat terminate-seat ; do
f686d7
  (( $+functions[_loginctl_$fun] )) || _loginctl_$fun()
f686d7
  { _loginctl_seats }
f686d7
done
f686d7
f686d7
# Completion functions for ATTACH
f686d7
(( $+functions[_loginctl_attach] )) || _loginctl_attach()
f686d7
{
f686d7
  _loginctl_all_seats
f686d7
f686d7
  _arguments -w -C -S -s \
f686d7
    ':seat:_loginctl_seats' \
f686d7
    '*:device:_files'
f686d7
}
f686d7
f686d7
# no loginctl completion for:
f686d7
# [STANDALONE]='list-sessions list-users list-seats flush-devices'
f686d7
f686d7
(( $+functions[_loginctl_command] )) || _loginctl_command()
f686d7
{
f686d7
  local -a _loginctl_cmds
f686d7
  _loginctl_cmds=(
f686d7
    "list-sessions:List sessions"
f686d7
    "session-status:Show session status"
f686d7
    "show-session:Show properties of one or more sessions"
f686d7
    "activate:Activate a session"
f686d7
    "lock-session:Screen lock one or more sessions"
f686d7
    "unlock-session:Screen unlock one or more sessions"
f686d7
    "terminate-session:Terminate one or more sessions"
f686d7
    "kill-session:Send signal to processes of a session"
f686d7
    "list-users:List users"
f686d7
    "user-status:Show user status"
f686d7
    "show-user:Show properties of one or more users"
f686d7
    "enable-linger:Enable linger state of one or more users"
f686d7
    "disable-linger:Disable linger state of one or more users"
f686d7
    "terminate-user:Terminate all sessions of one or more users"
f686d7
    "kill-user:Send signal to processes of a user"
f686d7
    "list-seats:List seats"
f686d7
    "seat-status:Show seat status"
f686d7
    "show-seat:Show properties of one or more seats"
f686d7
    "attach:Attach one or more devices to a seat"
f686d7
    "flush-devices:Flush all device associations"
f686d7
    "terminate-seat:Terminate all sessions on one or more seats"
f686d7
  )
f686d7
f686d7
  if (( CURRENT == 1 )); then
f686d7
    _describe -t commands 'loginctl command' _loginctl_cmds || compadd "$@"
f686d7
  else
f686d7
    local curcontext="$curcontext"
f686d7
f686d7
    cmd="${${_loginctl_cmds[(r)$words[1]:*]%%:*}}"
f686d7
f686d7
    if (( $#cmd )); then
f686d7
      curcontext="${curcontext%:*:*}:loginctl-${cmd}:"
f686d7
f686d7
      _call_function ret _loginctl_$cmd || _message 'no more arguments'
f686d7
    else
f686d7
      _message "unknown loginctl command: $words[1]"
f686d7
    fi
f686d7
    return ret
f686d7
  fi
f686d7
}
f686d7
f686d7
_hostnamectl_command() {
f686d7
    local -a _hostnamectl_cmds
f686d7
    _hostnamectl_cmds=(
f686d7
        "status:Show current hostname settings"
f686d7
        "set-hostname:Set system hostname"
f686d7
        "set-icon-name:Set icon name for host"
f686d7
    )
f686d7
    if (( CURRENT == 1 )); then
f686d7
        _describe -t commands 'hostnamectl commands' _hostnamectl_cmds || compadd "$@"
f686d7
    else
f686d7
        local curcontext="$curcontext"
f686d7
        cmd="${${_hostnamectl_cmds[(r)$words[1]:*]%%:*}}"
f686d7
        if (( $#cmd )); then
f686d7
            [[ $cmd == status ]] && msg="no options" || msg="options for $cmd"
f686d7
            _message "$msg"
f686d7
        else
f686d7
            _message "unknown hostnamectl command: $words[1]"
f686d7
        fi
f686d7
    fi
f686d7
}
f686d7
f686d7
_localectl_set-locale() {
f686d7
    local -a _confs _locales
f686d7
    local expl suf
f686d7
    _locales=( ${(f)"$(_call_program locales "$service" list-locales)"} )
f686d7
    _confs=( ${${(f)"$(_call_program confs "locale 2>/dev/null")"}%\=*} )
f686d7
    if [[ -prefix 1 *\= ]]; then
f686d7
        local conf=${PREFIX%%\=*}
f686d7
        compset -P1 '*='
f686d7
        _wanted locales expl "locales configs" \
f686d7
            _combination localeconfs  confs=$conf locales "$@" -
f686d7
    else
f686d7
        compadd -S '='  $_confs
f686d7
    fi
f686d7
}
f686d7
f686d7
_localectl_set-keymap() {
f686d7
    local -a _keymaps
f686d7
    _keymaps=( ${(f)"$(_call_program locales "$service" list-keymaps)"} )
f686d7
    if (( CURRENT <= 3 )); then
f686d7
        _describe keymaps _keymaps
f686d7
    else
f686d7
        _message "no more options"
f686d7
    fi
f686d7
}
f686d7
f686d7
_localectl_set-x11-keymap() {
f686d7
    if (( $+commands[pkg-config] )); then
f686d7
        local -a _file _layout _model _variant _options
f686d7
        local _xorg_lst
f686d7
        _xorg_lst=${"$($commands[pkg-config] xkeyboard-config --variable=xkb_base)"}
f686d7
        _file=( ${(ps:\n\!:)"$(<$_xorg_lst/rules/xorg.lst)"} )
f686d7
        _layout=( ${${${(M)${(f)_file[1]}:#  *}#  }%% *} )
f686d7
        _model=( ${${${(M)${(f)_file[2]}:#  *}#  }%% *} )
f686d7
        _variant=( ${${${(M)${(f)_file[3]}:#  *}#  }%% *} )
f686d7
        _options=( ${${${(M)${(f)_file[4]}:#  *}#  }%% *} )
f686d7
        #_layout=( ${(f)"$( echo $_file[1] | awk '/^  / {print $1}' )"} )
f686d7
        #_model=( ${(f)"$(echo $_file[2] | awk '/^  / {print $1}')"} )
f686d7
        #_variant=( ${(f)"$(echo $_file[3] | awk '/^  / {print $1}')"} )
f686d7
        #_options=( ${(f)"$(echo ${_file[4]//:/\\:} | awk '/^  / {print $1}')"} )
f686d7
f686d7
        case $CURRENT in
f686d7
            2) _describe layouts _layout ;;
f686d7
            3) _describe models _model;;
f686d7
            4) _describe variants _variant;;
f686d7
            5) _describe options _options;;
f686d7
            *) _message "no more options"
f686d7
        esac
f686d7
    fi
f686d7
}
f686d7
f686d7
f686d7
_localectl_command() {
f686d7
    local -a _localectl_cmds
f686d7
    _localectl_cmds=(
f686d7
        'status:Show current locale settings'
f686d7
        'set-locale:Set system locale'
f686d7
        'list-locales:Show known locales'
f686d7
        'set-keymap:Set virtual console keyboard mapping'
f686d7
        'list-keymaps:Show known virtual console keyboard mappings'
f686d7
        'set-x11-keymap:Set X11 keyboard mapping'
f686d7
    )
f686d7
    if (( CURRENT == 1 )); then
f686d7
        _describe -t commands 'localectl command' _localectl_cmds
f686d7
    else
f686d7
        local curcontext="$curcontext"
f686d7
        cmd="${${_localectl_cmds[(r)$words[1]:*]%%:*}}"
f686d7
        if (( $+functions[_localectl_$cmd] )); then
f686d7
            _localectl_$cmd
f686d7
        else
f686d7
            _message "no more options"
f686d7
        fi
f686d7
    fi
f686d7
}
f686d7
f686d7
_timedatectl_set-timezone(){
f686d7
    local -a _timezones
f686d7
    _timezones=( ${(f)"$(_call_program timezones "${service}" list-timezones)"} )
f686d7
    compadd "$_timezones[@]"
f686d7
}
f686d7
f686d7
_timedatectl_set-time(){
f686d7
    _message "YYYY-MM-DD HH:MM:SS"
f686d7
}
f686d7
f686d7
_timedatectl_set-local-rtc(){
f686d7
    local -a _options
f686d7
    _options=(
f686d7
        '0:Maintain RTC in universal time'
f686d7
        '1:Maintain RTC in local time'
f686d7
    )
f686d7
    _describe options _options
f686d7
}
f686d7
f686d7
_timedatectl_set-ntp(){
f686d7
    local -a _options
f686d7
    _options=(
f686d7
        '0:Disable NTP based network time configuration'
f686d7
        '1:Enable NTP based network time configuration'
f686d7
    )
f686d7
    _describe options _options
f686d7
}
f686d7
f686d7
_timedatectl_command(){
f686d7
    local -a _timedatectl_cmds
f686d7
    _timedatectl_cmds=(
f686d7
        'status:Show current time settings'
f686d7
        'set-time:Set system time'
f686d7
        'set-timezone:Set system timezone'
f686d7
        'list-timezones:Show known timezones'
f686d7
        'set-local-rtc:Control whether RTC is in local time'
f686d7
        'set-ntp:Control whether NTP is enabled'
f686d7
    )
f686d7
    if (( CURRENT == 1 )); then
f686d7
        _describe -t commands 'timedatectl command' _timedatectl_cmds
f686d7
    else
f686d7
        local curcontext="$curcontext"
f686d7
        cmd="${${_timedatectl_cmds[(r)$words[1]:*]%%:*}}"
f686d7
        if (( $#cmd )); then
f686d7
            if (( $+functions[_timedatectl_$cmd] )); then
f686d7
                _timedatectl_$cmd
f686d7
            else
f686d7
                _message "no more options"
f686d7
            fi
f686d7
        else
f686d7
            _message "unknown timedatectl command: $words[1]"
f686d7
        fi
f686d7
    fi
f686d7
}
f686d7
_systemd-coredumpctl_command(){
f686d7
    local -a _systemd_coredumpctl_cmds
f686d7
    _systemd_coredumpctl_cmds=(
f686d7
            'list:List available coredumps'
f686d7
            'dump:Print coredump to std'
f686d7
    )
f686d7
    if (( CURRENT == 1 )); then
f686d7
        _describe -t commands 'systemd-coredumpctl command' _systemd_coredumpctl_cmds
f686d7
    else
f686d7
        local curcontext="$curcontext"
f686d7
        local -a _dumps
f686d7
        cmd="${${_systemd_coredumpctl_cmds[(r)$words[1]:*]%%:*}}"
f686d7
        if (( $#cmd  )); then
f686d7
			# user can set zstyle ':completion:*:*:systemd-coredumpctl:*' sort no for coredumps to be ordered by date, otherwise they get ordered by pid
f686d7
			_dumps=( "${(foa)$(systemd-coredumpctl list | awk 'BEGIN{OFS=":"} /^\s/ {sub(/[[ \t]+/, ""); print $5,$0}' 2>/dev/null)}" )
f686d7
            if [[ -n "$_dumps" ]]; then
f686d7
                _describe -t pids 'coredumps' _dumps
f686d7
            else
f686d7
                _message "no coredumps"
f686d7
            fi
f686d7
        else
f686d7
            _message "no more options"
f686d7
        fi
f686d7
f686d7
    fi
f686d7
f686d7
}
f686d7
f686d7
(( $+functions[_machinectl_command] )) || _machinectl_command()
f686d7
{
f686d7
  local -a _machinectl_cmds
f686d7
  _machinectl_cmds=(
f686d7
    "list:List currently running VMs/containers"
f686d7
    "status:Show VM/container status"
f686d7
    "show:Show properties of one or more VMs/containers"
f686d7
    "terminate:Terminate one or more VMs/containers"
f686d7
    "kill:Send signal to process or a VM/container"
f686d7
  )
f686d7
  if (( CURRENT == 1 )); then
f686d7
    _describe -t commands 'machinectl command' _machinectl_cmds || compadd "$@"
f686d7
  else
f686d7
    local curcontext="$curcontext"
f686d7
    cmd="${${_machinectl_cmds[(r)$words[1]:*]%%:*}}"
f686d7
    if (( $#cmd )); then
f686d7
      case $cmd in
f686d7
        list) msg="no options" ;;
f686d7
        *)
f686d7
          _machines=( "${(foa)$(machinectl list | awk '{print $1}')}" )
f686d7
          if [[ -n "$_machines" ]]; then
f686d7
            _describe 'machines' _machines
f686d7
          else
f686d7
            _message 'no machines'
f686d7
          fi
f686d7
      esac
f686d7
    else
f686d7
      _message "no more options"
f686d7
    fi
f686d7
  fi
f686d7
}
f686d7
f686d7
_udevadm_info(){
f686d7
    _arguments \
f686d7
        '--query=[Query the database for specified type of device data. It needs the --path or --name to identify the specified device.]:type:(name symlink path property all)' \
f686d7
        '--path=[The devpath of the device to query.]:sys files:_files -P /sys/ -W /sys' \
f686d7
        '--name=[The name of the device node or a symlink to query]:device files:_files -P /dev/ -W /dev' \
f686d7
        '--root[Print absolute paths in name or symlink query.]' \
f686d7
        '--attribute-walk[Print all sysfs properties of the specified device that can be used in udev rules to match the specified device]' \
f686d7
        '--export[Print output as key/value pairs.]' \
f686d7
        '--export-prefix=[Add a prefix to the key name of exported values.]:prefix' \
f686d7
        '--device-id-of-file=[Print major/minor numbers of the underlying device, where the file lives on.]:files:_udevadm_mounts' \
f686d7
        '--export-db[Export the content of the udev database.]' \
f686d7
        '--cleanup-db[Cleanup the udev database.]'
f686d7
}
f686d7
f686d7
_udevadm_trigger(){
f686d7
    _arguments \
f686d7
        '--verbose[Print the list of devices which will be triggered.]' \
f686d7
        '--dry-run[Do not actually trigger the event.]' \
f686d7
        '--type=[Trigger a specific type of devices.]:types:(devices subsystems failed)' \
f686d7
        '--action=[Type of event to be triggered.]:actions:(add change remove)' \
f686d7
        '--subsystem-match=[Trigger events for devices which belong to a matching subsystem.]' \
f686d7
        '--subsystem-nomatch=[Do not trigger events for devices which belong to a matching subsystem.]' \
f686d7
        '--attr-match=attribute=[Trigger events for devices with a matching sysfs attribute.]' \
f686d7
        '--attr-nomatch=attribute=[Do not trigger events for devices with a matching sysfs attribute.]' \
f686d7
        '--property-match=[Trigger events for devices with a matching property value.]' \
f686d7
        '--tag-match=property[Trigger events for devices with a matching tag.]' \
f686d7
        '--sysname-match=[Trigger events for devices with a matching sys device name.]' \
f686d7
        '--parent-match=[Trigger events for all children of a given device.]'
f686d7
}
f686d7
f686d7
_udevadm_settle(){
f686d7
    _arguments \
f686d7
       '--timeout=[Maximum number of seconds to wait for the event queue to become empty.]' \
f686d7
       '--seq-start=[Wait only for events after the given sequence number.]' \
f686d7
       '--seq-end=[Wait only for events before the given sequence number.]' \
f686d7
       '--exit-if-exists=[Stop waiting if file exists.]:files:_files' \
f686d7
       '--quiet[Do not print any output, like the remaining queue entries when reaching the timeout.]' \
f686d7
       '--help[Print help text.]'
f686d7
}
f686d7
f686d7
_udevadm_control(){
f686d7
    _arguments \
f686d7
        '--exit[Signal and wait for systemd-udevd to exit.]' \
f686d7
        '--log-priority=[Set the internal log level of systemd-udevd.]:priorities:(err info debug)' \
f686d7
        '--stop-exec-queue[Signal systemd-udevd to stop executing new events. Incoming events will be queued.]' \
f686d7
        '--start-exec-queue[Signal systemd-udevd to enable the execution of events.]' \
f686d7
        '--reload[Signal systemd-udevd to reload the rules files and other databases like the kernel module index.]' \
f686d7
        '--property=[Set a global property for all events.]' \
f686d7
        '--children-max=[Set the maximum number of events.]' \
f686d7
        '--timeout=[The maximum number of seconds to wait for a reply from systemd-udevd.]' \
f686d7
        '--help[Print help text.]'
f686d7
}
f686d7
f686d7
_udevadm_monitor(){
f686d7
    _arguments \
f686d7
        '--kernel[Print the kernel uevents.]' \
f686d7
        '--udev[Print the udev event after the rule processing.]' \
f686d7
        '--property[Also print the properties of the event.]' \
f686d7
        '--subsystem-match=[Filter events by subsystem/\[devtype\].]' \
f686d7
        '--tag-match=[Filter events by property.]' \
f686d7
        '--help[Print help text.]'
f686d7
}
f686d7
f686d7
_udevadm_test(){
f686d7
    _arguments \
f686d7
        '--action=[The action string.]:actions:(add change remove)' \
f686d7
        '--subsystem=[The subsystem string.]' \
f686d7
        '--help[Print help text.]' \
f686d7
        '*::devpath:_files -P /sys/ -W /sys'
f686d7
}
f686d7
f686d7
_udevadm_test-builtin(){
f686d7
    if (( CURRENT == 2 )); then
f686d7
    _arguments \
f686d7
        '--help[Print help text]' \
f686d7
        '*::builtins:(blkid btrfs hwdb input_id kmod path_id usb_id uaccess)'
f686d7
    elif  (( CURRENT == 3 )); then
f686d7
        _arguments \
f686d7
            '--help[Print help text]' \
f686d7
            '*::syspath:_files -P /sys -W /sys'
f686d7
    else
f686d7
        _arguments \
f686d7
            '--help[Print help text]'
f686d7
    fi
f686d7
}
f686d7
f686d7
_udevadm_mounts(){
f686d7
  local dev_tmp dpath_tmp mp_tmp mline
f686d7
f686d7
    tmp=( "${(@f)$(< /etc/mtab)}" )
f686d7
    dev_tmp=( "${(@)${(@)tmp%% *}:#none}" )
f686d7
    mp_tmp=( "${(@)${(@)tmp#* }%% *}" )
f686d7
f686d7
  local MATCH
f686d7
  mp_tmp=("${(@q)mp_tmp//(#m)\\[0-7](#c3)/${(#)$(( 8#${MATCH[2,-1]} ))}}")
f686d7
  dpath_tmp=( "${(@Mq)dev_tmp:#/*}" )
f686d7
  dev_tmp=( "${(@q)dev_tmp:#/*}" )
f686d7
f686d7
  _alternative \
f686d7
    'device-paths: device path:compadd -a dpath_tmp' \
f686d7
    'directories:mount point:compadd -a mp_tmp'
f686d7
}
f686d7
f686d7
f686d7
_udevadm_command(){
f686d7
    local -a _udevadm_cmds
f686d7
    _udevadm_cmds=(
f686d7
        'info:query sysfs or the udev database'
f686d7
        'trigger:request events from the kernel'
f686d7
        'settle:wait for the event queue to finish'
f686d7
        'control:control the udev daemon'
f686d7
        'monitor:listen to kernel and udev events'
f686d7
        'test:test an event run'
f686d7
        'test-builtin:test a built-in command'
f686d7
    )
f686d7
f686d7
    if ((CURRENT == 1)); then
f686d7
        _describe -t commands 'udevadm commands' _udevadm_cmds
f686d7
    else
f686d7
        local curcontext="$curcontext"
f686d7
        cmd="${${_udevadm_cmds[(r)$words[1]:*]%%:*}}"
f686d7
        if (($#cmd)); then
f686d7
            if (( $+functions[_udevadm_$cmd] )); then
f686d7
                _udevadm_$cmd
f686d7
            else
f686d7
                _message "no options for $cmd"
f686d7
            fi
f686d7
        else
f686d7
            _message "no more options"
f686d7
        fi
f686d7
    fi
f686d7
}
f686d7
f686d7
_ctls "$@"
f686d7
f686d7
#vim: set ft=zsh sw=4 ts=4 et