mirror of
https://codeberg.org/icewind/evdev-shortcut.git
synced 2026-06-03 18:14:10 +02:00
don't unwrap in example
This commit is contained in:
parent
6e13b8e412
commit
742c49c162
1 changed files with 4 additions and 3 deletions
|
|
@ -5,16 +5,17 @@ use glob::GlobError;
|
||||||
use evdev_shortcut::{Key, Modifier, Shortcut, ShortcutListener};
|
use evdev_shortcut::{Key, Modifier, Shortcut, ShortcutListener};
|
||||||
|
|
||||||
#[tokio::main]
|
#[tokio::main]
|
||||||
async fn main() {
|
async fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||||
let listener = ShortcutListener::new();
|
let listener = ShortcutListener::new();
|
||||||
listener.add(Shortcut::new(&[Modifier::Meta], Key::KeyN));
|
listener.add(Shortcut::new(&[Modifier::Meta], Key::KeyN));
|
||||||
|
|
||||||
let devices =
|
let devices =
|
||||||
glob::glob("/dev/input/by-id/*-kbd").unwrap().collect::<Result<Vec<PathBuf>, GlobError>>().unwrap();
|
glob::glob("/dev/input/by-id/*-kbd")?.collect::<Result<Vec<PathBuf>, GlobError>>()?;
|
||||||
|
|
||||||
let mut stream = pin!(listener.listen(&devices).unwrap());
|
let mut stream = pin!(listener.listen(&devices)?);
|
||||||
|
|
||||||
while let Some(event) = stream.next().await {
|
while let Some(event) = stream.next().await {
|
||||||
println!("{} {}", event.shortcut, event.state);
|
println!("{} {}", event.shortcut, event.state);
|
||||||
}
|
}
|
||||||
|
Ok(())
|
||||||
}
|
}
|
||||||
Loading…
Add table
Add a link
Reference in a new issue