2 releases
0.1.2 | Apr 5, 2024 |
---|---|
0.1.1 | Apr 5, 2024 |
0.1.0 |
|
#559 in Unix APIs
466 downloads per month
Used in 2 crates
(via lazybar-core)
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