#[cfg(target_os = "linux")]
fn main() {
use openlogi_hook::{EventDisposition, Hook};
let hook = match Hook::start(|event| {
println!("{event:?}");
EventDisposition::PassThrough
}) {
Ok(h) => h,
Err(e) => {
eprintln!("error: failed to start hook: {e}");
std::process::exit(1);
}
};
println!("Hook running — move the mouse or click buttons. Press Ctrl-C to stop.");
let (tx, rx) = std::sync::mpsc::channel();
#[expect(
clippy::expect_used,
reason = "example binary; aborting on a failed handler install is fine"
)]
ctrlc::set_handler(move || {
let _ = tx.send(());
})
.expect("failed to set Ctrl-C handler");
rx.recv().ok();
hook.stop();
println!("Hook stopped.");
}
#[cfg(not(target_os = "linux"))]
fn main() {
eprintln!("print_events is a Linux-only smoke test (no-op on this platform).");
}