2个版本
0.1.2 | 2024年4月5日 |
---|---|
0.1.1 | 2024年4月5日 |
0.1.0 |
|
#429 in Unix APIs
3,803 monthly downloads
在3个crate中使用(通过lazybar-core)
11KB
81 lines
acpid-plug
Rust crate用于从acpid
监听Linux上的电源适配器插头事件。
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(())
}
依赖项
~3–11MB
~107K SLoC