2 releases
new 0.1.2 | Apr 5, 2024 |
---|---|
0.1.1 | Apr 5, 2024 |
0.1.0 |
|
#411 in Unix APIs
326 downloads per month
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–13MB
~120K SLoC