pilebones / go-udev

Simple udev implementation in Golang
GNU General Public License v3.0
95 stars 28 forks source link

go-udev trigger option? #16

Closed pwFoo closed 3 years ago

pwFoo commented 5 years ago

HI, I'll start some tests with go-udev if it could fit me needs.

With -monitor option I can detect changes like un-/plug devices?

And -info could be used for initial hardware detection and will trigger an event for each device in /sys/devices?

pilebones commented 5 years ago

Hi,

Indeed the monitor mode allows to detect change like (un)plug devices by subscribing and listening to a kernel Uevent channel. The binary display kernel-uevent message related to devices changes like udev's built-in tool : udevadm monitor.

But the info mode allows to list existing devices from /sys/devices kernel-tree, no event will be sent for each detected devices. The binary display a list of kernel-uevent properties related to already plugged devices like udev's built-in tool : udevadm info.

You could use the Go API according to your needs.