mirror of
https://codeberg.org/icewind/evdev-shortcut.git
synced 2026-06-03 10:04:11 +02:00
update to streams
This commit is contained in:
parent
aa5613a57c
commit
07d9edac20
10 changed files with 802 additions and 271 deletions
21
examples/listen.rs
Normal file
21
examples/listen.rs
Normal 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);
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue