Crate acpid_plug

Source
Expand description
use futures_util::StreamExt;

#[tokio::main(flavor = "current_thread")]
async fn main() -> std::io::Result<()> {
    let mut ac_plug_events = acpid_plug::connect().await?;

    while let Some(event) = ac_plug_events.next().await {
        match event {
            Ok(event) => println!("{:?}", event),
            Err(why) => eprintln!("error: {}", why),
        }
    }

    Ok(())
}

Structs§

AcPlugEvents
A stream of power adapter plug events.

Enums§

Event
Whether the power adapter has been plugged or unplugged.

Functions§

connect
Listens for AC plug events from /var/run/acpid.socket.
with_socket
Listens for AC plug events from a custom socket.