a06225fcc168cc3e62edc7efcb42d94cf68f159aWilliam Giokas#compdef udevadm
a06225fcc168cc3e62edc7efcb42d94cf68f159aWilliam Giokas_udevadm_info(){
a06225fcc168cc3e62edc7efcb42d94cf68f159aWilliam Giokas '--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)' \
a06225fcc168cc3e62edc7efcb42d94cf68f159aWilliam Giokas '--path=[The devpath of the device to query.]:sys files:_files -P /sys/ -W /sys' \
a06225fcc168cc3e62edc7efcb42d94cf68f159aWilliam Giokas '--name=[The name of the device node or a symlink to query]:device files:_files -P /dev/ -W /dev' \
a06225fcc168cc3e62edc7efcb42d94cf68f159aWilliam Giokas '--root[Print absolute paths in name or symlink query.]' \
a06225fcc168cc3e62edc7efcb42d94cf68f159aWilliam Giokas '--attribute-walk[Print all sysfs properties of the specified device that can be used in udev rules to match the specified device]' \
a06225fcc168cc3e62edc7efcb42d94cf68f159aWilliam Giokas '--export[Print output as key/value pairs.]' \
a06225fcc168cc3e62edc7efcb42d94cf68f159aWilliam Giokas '--export-prefix=[Add a prefix to the key name of exported values.]:prefix' \
a06225fcc168cc3e62edc7efcb42d94cf68f159aWilliam Giokas '--device-id-of-file=[Print major/minor numbers of the underlying device, where the file lives on.]:files:_udevadm_mounts' \
a06225fcc168cc3e62edc7efcb42d94cf68f159aWilliam Giokas '--export-db[Export the content of the udev database.]' \
a06225fcc168cc3e62edc7efcb42d94cf68f159aWilliam Giokas '--cleanup-db[Cleanup the udev database.]'
a06225fcc168cc3e62edc7efcb42d94cf68f159aWilliam Giokas_udevadm_trigger(){
a06225fcc168cc3e62edc7efcb42d94cf68f159aWilliam Giokas '--verbose[Print the list of devices which will be triggered.]' \
a06225fcc168cc3e62edc7efcb42d94cf68f159aWilliam Giokas '--dry-run[Do not actually trigger the event.]' \
a06225fcc168cc3e62edc7efcb42d94cf68f159aWilliam Giokas '--type=[Trigger a specific type of devices.]:types:(devices subsystems failed)' \
a06225fcc168cc3e62edc7efcb42d94cf68f159aWilliam Giokas '--action=[Type of event to be triggered.]:actions:(add change remove)' \
a06225fcc168cc3e62edc7efcb42d94cf68f159aWilliam Giokas '--subsystem-match=[Trigger events for devices which belong to a matching subsystem.]' \
a06225fcc168cc3e62edc7efcb42d94cf68f159aWilliam Giokas '--subsystem-nomatch=[Do not trigger events for devices which belong to a matching subsystem.]' \
a06225fcc168cc3e62edc7efcb42d94cf68f159aWilliam Giokas '--attr-match=attribute=[Trigger events for devices with a matching sysfs attribute.]' \
a06225fcc168cc3e62edc7efcb42d94cf68f159aWilliam Giokas '--attr-nomatch=attribute=[Do not trigger events for devices with a matching sysfs attribute.]' \
a06225fcc168cc3e62edc7efcb42d94cf68f159aWilliam Giokas '--property-match=[Trigger events for devices with a matching property value.]' \
a06225fcc168cc3e62edc7efcb42d94cf68f159aWilliam Giokas '--tag-match=property[Trigger events for devices with a matching tag.]' \
a06225fcc168cc3e62edc7efcb42d94cf68f159aWilliam Giokas '--sysname-match=[Trigger events for devices with a matching sys device name.]' \
a06225fcc168cc3e62edc7efcb42d94cf68f159aWilliam Giokas '--parent-match=[Trigger events for all children of a given device.]'
a06225fcc168cc3e62edc7efcb42d94cf68f159aWilliam Giokas_udevadm_settle(){
a06225fcc168cc3e62edc7efcb42d94cf68f159aWilliam Giokas '--timeout=[Maximum number of seconds to wait for the event queue to become empty.]' \
a06225fcc168cc3e62edc7efcb42d94cf68f159aWilliam Giokas '--seq-start=[Wait only for events after the given sequence number.]' \
a06225fcc168cc3e62edc7efcb42d94cf68f159aWilliam Giokas '--seq-end=[Wait only for events before the given sequence number.]' \
a06225fcc168cc3e62edc7efcb42d94cf68f159aWilliam Giokas '--exit-if-exists=[Stop waiting if file exists.]:files:_files' \
a06225fcc168cc3e62edc7efcb42d94cf68f159aWilliam Giokas '--quiet[Do not print any output, like the remaining queue entries when reaching the timeout.]' \
a06225fcc168cc3e62edc7efcb42d94cf68f159aWilliam Giokas '--help[Print help text.]'
a06225fcc168cc3e62edc7efcb42d94cf68f159aWilliam Giokas_udevadm_control(){
a06225fcc168cc3e62edc7efcb42d94cf68f159aWilliam Giokas '--exit[Signal and wait for systemd-udevd to exit.]' \
a06225fcc168cc3e62edc7efcb42d94cf68f159aWilliam Giokas '--log-priority=[Set the internal log level of systemd-udevd.]:priorities:(err info debug)' \
a06225fcc168cc3e62edc7efcb42d94cf68f159aWilliam Giokas '--stop-exec-queue[Signal systemd-udevd to stop executing new events. Incoming events will be queued.]' \
a06225fcc168cc3e62edc7efcb42d94cf68f159aWilliam Giokas '--start-exec-queue[Signal systemd-udevd to enable the execution of events.]' \
a06225fcc168cc3e62edc7efcb42d94cf68f159aWilliam Giokas '--reload[Signal systemd-udevd to reload the rules files and other databases like the kernel module index.]' \
a06225fcc168cc3e62edc7efcb42d94cf68f159aWilliam Giokas '--property=[Set a global property for all events.]' \
a06225fcc168cc3e62edc7efcb42d94cf68f159aWilliam Giokas '--children-max=[Set the maximum number of events.]' \
a06225fcc168cc3e62edc7efcb42d94cf68f159aWilliam Giokas '--timeout=[The maximum number of seconds to wait for a reply from systemd-udevd.]' \
a06225fcc168cc3e62edc7efcb42d94cf68f159aWilliam Giokas '--help[Print help text.]'
a06225fcc168cc3e62edc7efcb42d94cf68f159aWilliam Giokas_udevadm_monitor(){
a06225fcc168cc3e62edc7efcb42d94cf68f159aWilliam Giokas '--kernel[Print the kernel uevents.]' \
a06225fcc168cc3e62edc7efcb42d94cf68f159aWilliam Giokas '--udev[Print the udev event after the rule processing.]' \
a06225fcc168cc3e62edc7efcb42d94cf68f159aWilliam Giokas '--property[Also print the properties of the event.]' \
a06225fcc168cc3e62edc7efcb42d94cf68f159aWilliam Giokas '--subsystem-match=[Filter events by subsystem/\[devtype\].]' \
a06225fcc168cc3e62edc7efcb42d94cf68f159aWilliam Giokas '--tag-match=[Filter events by property.]' \
a06225fcc168cc3e62edc7efcb42d94cf68f159aWilliam Giokas '--help[Print help text.]'
a06225fcc168cc3e62edc7efcb42d94cf68f159aWilliam Giokas_udevadm_test(){
a06225fcc168cc3e62edc7efcb42d94cf68f159aWilliam Giokas '--action=[The action string.]:actions:(add change remove)' \
a06225fcc168cc3e62edc7efcb42d94cf68f159aWilliam Giokas '--subsystem=[The subsystem string.]' \
a06225fcc168cc3e62edc7efcb42d94cf68f159aWilliam Giokas '--help[Print help text.]' \
a06225fcc168cc3e62edc7efcb42d94cf68f159aWilliam Giokas '*::devpath:_files -P /sys/ -W /sys'
a06225fcc168cc3e62edc7efcb42d94cf68f159aWilliam Giokas_udevadm_test-builtin(){
a06225fcc168cc3e62edc7efcb42d94cf68f159aWilliam Giokas if (( CURRENT == 2 )); then
a06225fcc168cc3e62edc7efcb42d94cf68f159aWilliam Giokas '--help[Print help text]' \
0b99c9f8f0cbfe9ab3de443cb6f94ecd7d21eae3Tom Gundersen '*::builtins:(blkid btrfs hwdb input_id net_id net_setup_link kmod path_id usb_id uaccess)'
a06225fcc168cc3e62edc7efcb42d94cf68f159aWilliam Giokas elif (( CURRENT == 3 )); then
a06225fcc168cc3e62edc7efcb42d94cf68f159aWilliam Giokas '--help[Print help text]' \
a06225fcc168cc3e62edc7efcb42d94cf68f159aWilliam Giokas '*::syspath:_files -P /sys -W /sys'
a06225fcc168cc3e62edc7efcb42d94cf68f159aWilliam Giokas '--help[Print help text]'
a06225fcc168cc3e62edc7efcb42d94cf68f159aWilliam Giokas_udevadm_mounts(){
a06225fcc168cc3e62edc7efcb42d94cf68f159aWilliam Giokas local dev_tmp dpath_tmp mp_tmp mline
b3ccac01cc548cb3ea38a638b3c0dd5d0bc33cc2Lennart Poettering tmp=( "${(@f)$(< /proc/self/mounts)}" )
a06225fcc168cc3e62edc7efcb42d94cf68f159aWilliam Giokas dev_tmp=( "${(@)${(@)tmp%% *}:#none}" )
a06225fcc168cc3e62edc7efcb42d94cf68f159aWilliam Giokas mp_tmp=( "${(@)${(@)tmp#* }%% *}" )
a06225fcc168cc3e62edc7efcb42d94cf68f159aWilliam Giokas mp_tmp=("${(@q)mp_tmp//(#m)\\[0-7](#c3)/${(#)$(( 8#${MATCH[2,-1]} ))}}")
a06225fcc168cc3e62edc7efcb42d94cf68f159aWilliam Giokas dpath_tmp=( "${(@Mq)dev_tmp:#/*}" )
a06225fcc168cc3e62edc7efcb42d94cf68f159aWilliam Giokas dev_tmp=( "${(@q)dev_tmp:#/*}" )
a06225fcc168cc3e62edc7efcb42d94cf68f159aWilliam Giokas _alternative \
a06225fcc168cc3e62edc7efcb42d94cf68f159aWilliam Giokas 'device-paths: device path:compadd -a dpath_tmp' \
a06225fcc168cc3e62edc7efcb42d94cf68f159aWilliam Giokas 'directories:mount point:compadd -a mp_tmp'
a06225fcc168cc3e62edc7efcb42d94cf68f159aWilliam Giokas_udevadm_command(){
a06225fcc168cc3e62edc7efcb42d94cf68f159aWilliam Giokas local -a _udevadm_cmds
a06225fcc168cc3e62edc7efcb42d94cf68f159aWilliam Giokas _udevadm_cmds=(
a06225fcc168cc3e62edc7efcb42d94cf68f159aWilliam Giokas 'info:query sysfs or the udev database'
a06225fcc168cc3e62edc7efcb42d94cf68f159aWilliam Giokas 'trigger:request events from the kernel'
a06225fcc168cc3e62edc7efcb42d94cf68f159aWilliam Giokas 'settle:wait for the event queue to finish'
a06225fcc168cc3e62edc7efcb42d94cf68f159aWilliam Giokas 'control:control the udev daemon'
a06225fcc168cc3e62edc7efcb42d94cf68f159aWilliam Giokas 'monitor:listen to kernel and udev events'
a06225fcc168cc3e62edc7efcb42d94cf68f159aWilliam Giokas 'test:test an event run'
a06225fcc168cc3e62edc7efcb42d94cf68f159aWilliam Giokas 'test-builtin:test a built-in command'
a06225fcc168cc3e62edc7efcb42d94cf68f159aWilliam Giokas if ((CURRENT == 1)); then
a06225fcc168cc3e62edc7efcb42d94cf68f159aWilliam Giokas _describe -t commands 'udevadm commands' _udevadm_cmds
a06225fcc168cc3e62edc7efcb42d94cf68f159aWilliam Giokas local curcontext="$curcontext"
a06225fcc168cc3e62edc7efcb42d94cf68f159aWilliam Giokas cmd="${${_udevadm_cmds[(r)$words[1]:*]%%:*}}"
a06225fcc168cc3e62edc7efcb42d94cf68f159aWilliam Giokas if (($#cmd)); then
a06225fcc168cc3e62edc7efcb42d94cf68f159aWilliam Giokas if (( $+functions[_udevadm_$cmd] )); then
a06225fcc168cc3e62edc7efcb42d94cf68f159aWilliam Giokas _udevadm_$cmd
a06225fcc168cc3e62edc7efcb42d94cf68f159aWilliam Giokas _message "no options for $cmd"
a06225fcc168cc3e62edc7efcb42d94cf68f159aWilliam Giokas _message "no more options"
a06225fcc168cc3e62edc7efcb42d94cf68f159aWilliam Giokas '--debug[Print debug messages to stderr]' \
a06225fcc168cc3e62edc7efcb42d94cf68f159aWilliam Giokas '--version[Print version number]' \
a06225fcc168cc3e62edc7efcb42d94cf68f159aWilliam Giokas '--help[Print help text]' \
a06225fcc168cc3e62edc7efcb42d94cf68f159aWilliam Giokas '*::udevadm commands:_udevadm_command'