#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

#1066 in Unix APIs

Download history 68/week @ 2024-11-15 76/week @ 2024-11-22 80/week @ 2024-11-29 131/week @ 2024-12-06 136/week @ 2024-12-13 181/week @ 2024-12-20 167/week @ 2024-12-27 139/week @ 2025-01-03 336/week @ 2025-01-10 297/week @ 2025-01-17 189/week @ 2025-01-24 137/week @ 2025-01-31 200/week @ 2025-02-07 141/week @ 2025-02-14 310/week @ 2025-02-21 253/week @ 2025-02-28

934 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
~110K SLoC