diff --git a/espanso-detect/src/evdev/device.rs b/espanso-detect/src/evdev/device.rs index f71c1dc..e48d574 100644 --- a/espanso-detect/src/evdev/device.rs +++ b/espanso-detect/src/evdev/device.rs @@ -199,26 +199,70 @@ impl Device { } } - pub fn update_modifier_state(&mut self, modifiers_state: &ModifiersState, modifiers_map: &HashMap) { + pub fn update_modifier_state( + &mut self, + modifiers_state: &ModifiersState, + modifiers_map: &HashMap, + ) { if modifiers_state.alt { - self.update_key(*modifiers_map.get("alt").expect("unable to find modifiers key in map"), true); + self.update_key( + *modifiers_map + .get("alt") + .expect("unable to find modifiers key in map"), + true, + ); } if modifiers_state.ctrl { - self.update_key(*modifiers_map.get("ctrl").expect("unable to find modifiers key in map"), true); + self.update_key( + *modifiers_map + .get("ctrl") + .expect("unable to find modifiers key in map"), + true, + ); } if modifiers_state.meta { - self.update_key(*modifiers_map.get("meta").expect("unable to find modifiers key in map"), true); + self.update_key( + *modifiers_map + .get("meta") + .expect("unable to find modifiers key in map"), + true, + ); } if modifiers_state.num_lock { - self.update_key(*modifiers_map.get("num_lock").expect("unable to find modifiers key in map"), true); - self.update_key(*modifiers_map.get("num_lock").expect("unable to find modifiers key in map"), false); + self.update_key( + *modifiers_map + .get("num_lock") + .expect("unable to find modifiers key in map"), + true, + ); + self.update_key( + *modifiers_map + .get("num_lock") + .expect("unable to find modifiers key in map"), + false, + ); } if modifiers_state.shift { - self.update_key(*modifiers_map.get("shift").expect("unable to find modifiers key in map"), true); + self.update_key( + *modifiers_map + .get("shift") + .expect("unable to find modifiers key in map"), + true, + ); } if modifiers_state.caps_lock { - self.update_key(*modifiers_map.get("caps_lock").expect("unable to find modifiers key in map"), true); - self.update_key(*modifiers_map.get("caps_lock").expect("unable to find modifiers key in map"), false); + self.update_key( + *modifiers_map + .get("caps_lock") + .expect("unable to find modifiers key in map"), + true, + ); + self.update_key( + *modifiers_map + .get("caps_lock") + .expect("unable to find modifiers key in map"), + false, + ); } } } diff --git a/espanso-detect/src/evdev/sync/mod.rs b/espanso-detect/src/evdev/sync/mod.rs index d42c9fc..f285132 100644 --- a/espanso-detect/src/evdev/sync/mod.rs +++ b/espanso-detect/src/evdev/sync/mod.rs @@ -36,4 +36,4 @@ pub use wayland::get_modifiers_state; pub fn get_modifiers_state() -> anyhow::Result> { // Fallback for non-wayland systems Ok(None) -} \ No newline at end of file +} diff --git a/espanso-detect/src/evdev/sync/wayland.rs b/espanso-detect/src/evdev/sync/wayland.rs index ed2f8d8..6d7ce6c 100644 --- a/espanso-detect/src/evdev/sync/wayland.rs +++ b/espanso-detect/src/evdev/sync/wayland.rs @@ -178,7 +178,7 @@ pub fn get_modifiers_state() -> Result> { redraw(&mut pool, window.surface(), dimensions).expect("Failed to draw"); } None => { - let result_clone= result.clone(); + let result_clone = result.clone(); let result_ref = result_clone.borrow(); if let Some(result) = &*result_ref { @@ -191,10 +191,7 @@ pub fn get_modifiers_state() -> Result> { display.flush().unwrap(); event_loop - .dispatch( - Some(std::time::Duration::from_millis(10)), - &mut next_action, - ) + .dispatch(Some(std::time::Duration::from_millis(10)), &mut next_action) .unwrap(); } diff --git a/espanso-detect/src/layout/mod.rs b/espanso-detect/src/layout/mod.rs index d24fe7e..0215529 100644 --- a/espanso-detect/src/layout/mod.rs +++ b/espanso-detect/src/layout/mod.rs @@ -46,4 +46,4 @@ pub fn get_active_layout() -> Option { pub fn get_active_layout() -> Option { // Not available on Windows and macOS yet None -} \ No newline at end of file +} diff --git a/espanso-detect/src/layout/x11.rs b/espanso-detect/src/layout/x11.rs index fe3018c..c60d649 100644 --- a/espanso-detect/src/layout/x11.rs +++ b/espanso-detect/src/layout/x11.rs @@ -22,16 +22,13 @@ use std::process::Command; use log::error; pub fn get_active_layout() -> Option { - match Command::new("setxkbmap") - .arg("-query") - .output() - { + match Command::new("setxkbmap").arg("-query").output() { Ok(output) => { let output_str = String::from_utf8_lossy(&output.stdout); let layout_line = output_str.lines().find(|line| line.contains("layout:"))?; let layout_raw: Vec<&str> = layout_line.split("layout:").collect(); - Some(layout_raw.get(1)?.trim().to_string()) - }, + Some(layout_raw.get(1)?.trim().to_string()) + } Err(err) => { error!( "unable to retrieve current keyboard layout with 'setxkbmap': {}", diff --git a/espanso-detect/src/lib.rs b/espanso-detect/src/lib.rs index 636caf0..393b40e 100644 --- a/espanso-detect/src/lib.rs +++ b/espanso-detect/src/lib.rs @@ -94,7 +94,10 @@ impl Default for SourceCreationOptions { #[cfg(target_os = "windows")] pub fn get_source(options: SourceCreationOptions) -> Result> { info!("using Win32Source"); - Ok(Box::new(win32::Win32Source::new(&options.hotkeys, options.win32_exclude_orphan_events))) + Ok(Box::new(win32::Win32Source::new( + &options.hotkeys, + options.win32_exclude_orphan_events, + ))) } #[cfg(target_os = "macos")]