Exemple #1
0
func (self *Monitor) Recv() (MonitorDevice, error) {
	for {
		udev_device := C.udev_monitor_receive_device(self.udev_monitor)

		if udev_device == nil {
			continue
		}

		// device
		var device MonitorDevice

		if err := device.fromUdev(udev_device); err != nil {
			return device, err
		}

		cAction := C.udev_device_get_action(udev_device)
		if cAction != nil {
			device.Action = C.GoString(cAction)
		}

		return device, nil
	}
}
Exemple #2
0
func (d Device) Action() string {
	return C.GoString(C.udev_device_get_action(d.ptr))
}
Exemple #3
0
// Action returns the action for the event.
// This is only valid if the device was received through a monitor.
// Devices read from sys do not have an action string.
// Usual actions are: add, remove, change, online, offline.
func (d *Device) Action() string {
	d.lock()
	defer d.unlock()
	return C.GoString(C.udev_device_get_action(d.ptr))
}