#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

#580 in Unix APIs

Download history 102/week @ 2024-10-27 118/week @ 2024-11-03 63/week @ 2024-11-10 71/week @ 2024-11-17 71/week @ 2024-11-24 106/week @ 2024-12-01 116/week @ 2024-12-08 162/week @ 2024-12-15 187/week @ 2024-12-22 139/week @ 2024-12-29 253/week @ 2025-01-05 247/week @ 2025-01-12 302/week @ 2025-01-19 159/week @ 2025-01-26 187/week @ 2025-02-02 139/week @ 2025-02-09

817 downloads per month
Used in 2 crates (via lazybar-core)

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–11MB
~111K SLoC