client lib

This commit is contained in:
Robin Appelman 2020-04-11 14:32:28 +02:00
commit 6b81b14b81
4 changed files with 130 additions and 0 deletions

23
examples/client.rs Normal file
View file

@ -0,0 +1,23 @@
use shortcutd_client::{Shortcut, ShortcutClient};
use std::error::Error;
use std::time::Duration;
fn main() -> Result<(), Box<dyn Error>> {
let mut client = ShortcutClient::new()?;
let shortcut: Shortcut = "<Ctrl><Alt>-KeyP".parse()?;
client.register(shortcut, |s| {
eprintln!("shortcut1 {}", s);
})?;
let shortcut: Shortcut = "<Ctrl><Alt>-KeyO".parse()?;
client.register(shortcut, |s| {
eprintln!("shortcut2 {}", s);
})?;
loop {
client.process(Duration::from_millis(1000))?;
}
}