udev-dotnet 261.2.0

dotnet add package udev-dotnet --version 261.2.0
                    
NuGet\Install-Package udev-dotnet -Version 261.2.0
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="udev-dotnet" Version="261.2.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="udev-dotnet" Version="261.2.0" />
                    
Directory.Packages.props
<PackageReference Include="udev-dotnet" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add udev-dotnet --version 261.2.0
                    
#r "nuget: udev-dotnet, 261.2.0"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package udev-dotnet@261.2.0
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=udev-dotnet&version=261.2.0
                    
Install as a Cake Addin
#tool nuget:?package=udev-dotnet&version=261.2.0
                    
Install as a Cake Tool

udev-dotnet

udev-dotnet are .NET bindings for libudev, the library for enumerating Linux devices and receiving hotplug events.

Usage

Enumerate devices:

using Udev;

using var udev = new UdevContext();
foreach (var device in udev.EnumerateDevices("block"))
{
    using (device)
    {
        Console.WriteLine($"{device.Devnode}: {device.GetPropertyValue("ID_MODEL")}");
    }
}

Watch for hotplug events:

using var monitor = udev.CreateMonitor();
monitor.FilterMatchSubsystemDevtype("usb");
monitor.EnableReceiving();

while (monitor.Wait(TimeSpan.FromSeconds(1)))
{
    while (monitor.TryReceiveDevice() is { } device)
    {
        using (device)
        {
            Console.WriteLine($"{device.Action}: {device.Devnode ?? device.Syspath}");
        }
    }
}

monitor.Fd exposes the netlink socket for integration with your own poll loop.

Look up a single device and its metadata:

using var disk = udev.GetDeviceFromSubsystemSysname("block", "sda");
Console.WriteLine(string.Join('\n', disk.Devlinks));

using var controller = disk.GetParent("pci");
Console.WriteLine(controller?.GetSysattrValue("vendor"));

Testing

dotnet test
sudo chmod a+w /sys/class/mem/null/uevent   # optional: enables the monitor event test

Sample

samples/Udev.NET.Sample is a small udevadm-like tool:

dotnet run --project samples/Udev.NET.Sample -- list block
dotnet run --project samples/Udev.NET.Sample -- info /sys/class/mem/null
dotnet run --project samples/Udev.NET.Sample -- monitor usb

Regenerating the bindings

git submodule update --init
dotnet tool restore
sh eng/generate.sh

Requires a system clang for its builtin-header resource directory.

Product Compatible and additional computed target framework versions.
.NET net8.0 is compatible.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed.  net9.0 was computed.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 was computed.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • net8.0

    • No dependencies.

NuGet packages (1)

Showing the top 1 NuGet packages that depend on udev-dotnet:

Package Downloads
libinput-dotnet

.NET bindings for libinput

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
261.2.0 812 7/28/2026