https://github.com/canonical/udev.dart
API for enumerating and introspecting local devices
https://github.com/canonical/udev.dart
dart ffi udev
Last synced: 6 months ago
JSON representation
API for enumerating and introspecting local devices
- Host: GitHub
- URL: https://github.com/canonical/udev.dart
- Owner: canonical
- License: mpl-2.0
- Created: 2022-06-22T14:34:34.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2025-05-19T04:41:18.000Z (8 months ago)
- Last Synced: 2025-05-25T12:11:57.284Z (8 months ago)
- Topics: dart, ffi, udev
- Language: Dart
- Homepage: https://pub.dev/packages/udev
- Size: 79.1 KB
- Stars: 10
- Watchers: 9
- Forks: 2
- Open Issues: 9
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- Contributing: CONTRIBUTING.md
- License: LICENSE
Awesome Lists containing this project
README
# udev.dart
[](https://github.com/canonical/geoclue.dart/actions/workflows/tests.yaml)
[](https://codecov.io/gh/canonical/udev.dart)
[udev](https://www.freedesktop.org/software/systemd/man/libudev.html) — API for enumerating and introspecting local devices
## Querying devices
```dart
print(UdevDevice.fromSyspath('/sys/devices/<...>'));
print(UdevDevice.fromDevnum('b', 66304));
print(UdevDevice.fromSubsystemSysname('net', 'eth0'));
print(UdevDevice.fromDeviceId('c128:1'));
```
## Enumerating devices
```dart
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
```dart
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](CONTRIBUTING.md) for more details.