#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

#559 in Unix APIs

Download history 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 296/week @ 2024-09-16 349/week @ 2024-09-23 301/week @ 2024-09-30 272/week @ 2024-10-07 152/week @ 2024-10-14 65/week @ 2024-10-21 115/week @ 2024-10-28 106/week @ 2024-11-04

466 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
~105K SLoC