diff --git a/komorebi-core/src/lib.rs b/komorebi-core/src/lib.rs index 4e4b4a1c..699c10f4 100644 --- a/komorebi-core/src/lib.rs +++ b/komorebi-core/src/lib.rs @@ -93,6 +93,7 @@ pub enum SocketMessage { Query(StateQuery), FocusFollowsMouse(FocusFollowsMouseImplementation, bool), ToggleFocusFollowsMouse(FocusFollowsMouseImplementation), + MouseFollowsFocus(bool), ToggleMouseFollowsFocus, AddSubscriber(String), RemoveSubscriber(String), diff --git a/komorebi/src/process_command.rs b/komorebi/src/process_command.rs index 7e56591b..7e9ef417 100644 --- a/komorebi/src/process_command.rs +++ b/komorebi/src/process_command.rs @@ -453,6 +453,9 @@ impl WindowManager { let mut pipes = SUBSCRIPTION_PIPES.lock(); pipes.remove(&subscriber); } + SocketMessage::MouseFollowsFocus(enable) => { + self.mouse_follows_focus = enable; + } SocketMessage::ToggleMouseFollowsFocus => { self.mouse_follows_focus = !self.mouse_follows_focus; } diff --git a/komorebic.lib.sample.ahk b/komorebic.lib.sample.ahk index dc732add..c43d873c 100644 --- a/komorebic.lib.sample.ahk +++ b/komorebic.lib.sample.ahk @@ -244,6 +244,10 @@ ToggleFocusFollowsMouse(implementation) { Run, komorebic.exe toggle-focus-follows-mouse --implementation %implementation%, , Hide } +MouseFollowsFocus(boolean_state) { + Run, komorebic.exe mouse-follows-focus %boolean_state%, , Hide +} + ToggleMouseFollowsFocus() { Run, komorebic.exe toggle-mouse-follows-focus, , Hide } diff --git a/komorebic/src/main.rs b/komorebic/src/main.rs index d3305791..7d84e1ac 100644 --- a/komorebic/src/main.rs +++ b/komorebic/src/main.rs @@ -88,6 +88,7 @@ gen_enum_subcommand_args! { FlipLayout: Flip, ChangeLayout: DefaultLayout, WatchConfiguration: BooleanState, + MouseFollowsFocus: BooleanState, Query: StateQuery, } @@ -499,6 +500,9 @@ enum SubCommand { /// Toggle focus follows mouse for the operating system #[clap(setting = AppSettings::ArgRequiredElseHelp)] ToggleFocusFollowsMouse(ToggleFocusFollowsMouse), + /// Enable or disable mouse follows focus on all workspaces + #[clap(setting = AppSettings::ArgRequiredElseHelp)] + MouseFollowsFocus(MouseFollowsFocus), /// Toggle mouse follows focus on all workspaces ToggleMouseFollowsFocus, /// Generate a library of AutoHotKey helper functions @@ -924,6 +928,14 @@ fn main() -> Result<()> { SubCommand::ToggleMouseFollowsFocus => { send_message(&*SocketMessage::ToggleMouseFollowsFocus.as_bytes()?)?; } + SubCommand::MouseFollowsFocus(arg) => { + let enable = match arg.boolean_state { + BooleanState::Enable => true, + BooleanState::Disable => false, + }; + + send_message(&*SocketMessage::MouseFollowsFocus(enable).as_bytes()?)?; + } } Ok(())