update to streams

This commit is contained in:
Robin Appelman 2023-06-17 15:52:26 +02:00
commit 07d9edac20
10 changed files with 802 additions and 271 deletions

21
examples/listen.rs Normal file
View file

@ -0,0 +1,21 @@
use std::path::PathBuf;
use futures::{pin_mut, StreamExt};
use glob::GlobError;
use evdev_shortcut::{Key, Modifier, Shortcut, ShortcutListener};
#[tokio::main]
async fn main() {
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();
let stream = listener.listen(&devices).unwrap();
pin_mut!(stream);
while let Some(shortcut) = stream.next().await {
dbg!(shortcut);
}
}