From 4ae9d318d7f8771469259f39b8ea8fc5aef6d102 Mon Sep 17 00:00:00 2001 From: Tait Hoyem Date: Sun, 27 Nov 2022 18:39:37 -0700 Subject: [PATCH] Fix #63 --- sohkd/Cargo.toml | 2 +- sohkd/src/main.rs | 16 +++++++--------- 2 files changed, 8 insertions(+), 10 deletions(-) diff --git a/sohkd/Cargo.toml b/sohkd/Cargo.toml index 2c80cea9..4656fef4 100644 --- a/sohkd/Cargo.toml +++ b/sohkd/Cargo.toml @@ -13,7 +13,7 @@ authors = [ [dependencies] clap.workspace = true env_logger = "0.10.0" -evdev = { version = "0.12.0", features = ["tokio"] } +evdev = { version = "0.11.6", features = ["tokio"] } itertools = "0.10.5" log = "0.4.17" nix.workspace = true diff --git a/sohkd/src/main.rs b/sohkd/src/main.rs index 1319759e..39a48645 100644 --- a/sohkd/src/main.rs +++ b/sohkd/src/main.rs @@ -160,12 +160,11 @@ async fn main() -> Result<(), Box> { // } let arg_devices = arg_devices.collect::>(); evdev::enumerate() - .filter(|(_, device)| arg_devices.contains(&device.name().unwrap_or(""))) - .map(|(_, device)| device) + .filter(|device| arg_devices.contains(&device.name().unwrap_or(""))) .collect() } else { log::trace!("Attempting to find all keyboard file descriptors."); - evdev::enumerate().filter(check_device_is_keyboard).map(|(_, device)| device).collect() + evdev::enumerate().filter(check_device_is_keyboard).collect() } }; @@ -253,14 +252,14 @@ async fn main() -> Result<(), Box> { match signal { SIGUSR1 => { execution_is_paused = true; - for (_, mut device) in evdev::enumerate().filter(check_device_is_keyboard) { + for mut device in evdev::enumerate().filter(check_device_is_keyboard) { let _ = device.ungrab(); } } SIGUSR2 => { execution_is_paused = false; - for (_, mut device) in evdev::enumerate().filter(check_device_is_keyboard) { + for mut device in evdev::enumerate().filter(check_device_is_keyboard) { let _ = device.grab(); } } @@ -271,7 +270,7 @@ async fn main() -> Result<(), Box> { } SIGINT => { - for (_, mut device) in evdev::enumerate().filter(check_device_is_keyboard) { + for mut device in evdev::enumerate().filter(check_device_is_keyboard) { let _ = device.ungrab(); } log::warn!("Received SIGINT signal, exiting..."); @@ -279,7 +278,7 @@ async fn main() -> Result<(), Box> { } _ => { - for (_, mut device) in evdev::enumerate().filter(check_device_is_keyboard) { + for mut device in evdev::enumerate().filter(check_device_is_keyboard) { let _ = device.ungrab(); } @@ -422,8 +421,7 @@ pub fn check_input_group() -> Result<(), Box> { } } -pub fn check_device_is_keyboard(tup: &(PathBuf, Device)) -> bool { - let device = &tup.1; +pub fn check_device_is_keyboard(device: &Device) -> bool { if device.supported_keys().map_or(false, |keys| keys.contains(Key::KEY_ENTER)) { if device.name() == Some("sohkd virtual output") { return false;