don't unwrap in example

This commit is contained in:
Robin Appelman 2025-06-09 17:08:50 +02:00
commit 742c49c162

View file

@ -5,16 +5,17 @@ use glob::GlobError;
use evdev_shortcut::{Key, Modifier, Shortcut, ShortcutListener};
#[tokio::main]
async fn main() {
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let listener = ShortcutListener::new();
listener.add(Shortcut::new(&[Modifier::Meta], Key::KeyN));
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 {
println!("{} {}", event.shortcut, event.state);
}
Ok(())
}