#linux #battery #acpi

acpid_plug

Listen to AC adapter plug events from acpid

2 releases

0.1.2 Apr 5, 2024
0.1.1 Apr 5, 2024
0.1.0 Apr 5, 2024

#369 in Unix APIs

Download history 321/week @ 2024-04-01 83/week @ 2024-04-08 390/week @ 2024-04-15 508/week @ 2024-04-22 641/week @ 2024-04-29 824/week @ 2024-05-06 623/week @ 2024-05-13 555/week @ 2024-05-20 521/week @ 2024-05-27 570/week @ 2024-06-03 366/week @ 2024-06-10 398/week @ 2024-06-17 496/week @ 2024-06-24 518/week @ 2024-07-01 611/week @ 2024-07-08

2,087 downloads per month

MPL-2.0 license

11KB
81 lines

acpid-plug

Rust crate for listening to AC adapter plug events on Linux from acpid.

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(())
}

lib.rs:

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(())
}

Dependencies

~3–14MB
~124K SLoC