Module smithay::backend::udev[][src]

Expand description

udev related functionality for automated device scanning

This module mainly provides the UdevBackend, which monitors available DRM devices and acts as an event source to be inserted in calloop, generating events whenever these devices change.

Note: Once inserted into the event loop, the UdevBackend will only notify you about changes in the device list. To get an initial snapshot of the state during your initialization, you need to call its device_list method.

use smithay::backend::udev::{UdevBackend, UdevEvent};

let udev = UdevBackend::new("seat0", None).expect("Failed to monitor udev.");

for (dev_id, node_path) in udev.device_list() {
    // process the initial list of devices
}

// setup the event source for long-term monitoring
loop_handle.insert_source(udev, |event, _, _dispatch_data| match event {
    UdevEvent::Added { device_id, path } => {
        // a new device has been added
    },
    UdevEvent::Changed { device_id } => {
        // a device has been changed
    },
    UdevEvent::Removed { device_id } => {
        // a device has been removed
    }
}).expect("Failed to insert the udev source into the event loop");

Additionally this contains some utility functions related to scanning.

See also anvil/src/udev.rs for pure hardware backed example of a compositor utilizing this backend.

Structs

Backend to monitor available drm devices.

Enums

Events generated by the UdevBackend, notifying you of changes in system devices

Functions

Returns the paths of all available GPU devices

Returns the loaded driver for a device named by it’s dev_t.

Returns the path of the primary GPU device if any