#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

#520 in Unix APIs

Download history 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 691/week @ 2024-07-08 508/week @ 2024-07-15 641/week @ 2024-07-22 498/week @ 2024-07-29 1633/week @ 2024-08-05 1095/week @ 2024-08-12 417/week @ 2024-08-19 347/week @ 2024-08-26 397/week @ 2024-09-02 373/week @ 2024-09-09 257/week @ 2024-09-16

1,421 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
~106K SLoC