API for enumerating and introspecting local devices
udev.dart
udev — API for enumerating and introspecting local devices
Querying devices
print(UdevDevice.fromSyspath('/sys/devices/<...>'));
print(UdevDevice.fromDevnum('b', 66304));
print(UdevDevice.fromSubsystemSysname('net', 'eth0'));
print(UdevDevice.fromDeviceId('c128:1'));
Enumerating devices
final context = UdevContext();
final syspaths = context.enumerateDevices(subsystems: ['usb']);
for (final syspath in syspaths) {
final device = UdevDevice.fromSyspath(syspath, context: context);
print(device);
}
Monitoring devices
final context = UdevContext();
final stream = context.monitorDevices(subsystems: ['usb'])
stream.timeout(const Duration(seconds: 60), onTimeout: (sink) => sink.close())
.listen(print);
Contributing to udev.dart
We welcome contributions! See the contribution guide for more details.