#linux #battery-acpi #acpi #battery

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

#1734 in Unix APIs

Download history 95/week @ 2026-01-18 80/week @ 2026-01-25 99/week @ 2026-02-01 81/week @ 2026-02-08 127/week @ 2026-02-15 107/week @ 2026-02-22 43/week @ 2026-03-01 47/week @ 2026-03-08 50/week @ 2026-03-15 65/week @ 2026-03-22 51/week @ 2026-03-29 86/week @ 2026-04-05 88/week @ 2026-04-12 110/week @ 2026-04-19 54/week @ 2026-04-26 106/week @ 2026-05-03

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

Dependencies

~2.5–5MB
~85K SLoC