diff --git a/Cargo.lock b/Cargo.lock index addfa728..70bede3b 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -577,9 +577,9 @@ checksum = "308cc39be01b73d0d18f82a0e7b2a3df85245f84af96fdddc5d202d27e47b86a" [[package]] name = "memoffset" -version = "0.6.4" +version = "0.6.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "59accc507f1338036a0477ef61afdae33cde60840f4dfe481319ce3ad116ddf9" +checksum = "5aa361d4faea93603064a027415f07bd8e1d5c88c9fbf68bf56a285428fd79ce" dependencies = [ "autocfg", ] diff --git a/README.md b/README.md index 8c4a945a..f29cc6c9 100644 --- a/README.md +++ b/README.md @@ -308,6 +308,7 @@ send-to-monitor Send the focused window to the specified mo send-to-workspace Send the focused window to the specified workspace focus-monitor Focus the specified monitor focus-workspace Focus the specified workspace on the focused monitor +focus-monitor-workspace Focus the specified workspace on the target monitor cycle-monitor Focus the monitor in the given cycle direction cycle-workspace Focus the workspace in the given cycle direction new-workspace Create and append a new workspace on the focused monitor diff --git a/komorebi-core/src/lib.rs b/komorebi-core/src/lib.rs index bfa0e2e1..22b069c1 100644 --- a/komorebi-core/src/lib.rs +++ b/komorebi-core/src/lib.rs @@ -76,6 +76,7 @@ pub enum SocketMessage { CycleFocusWorkspace(CycleDirection), FocusMonitorNumber(usize), FocusWorkspaceNumber(usize), + FocusMonitorWorkspaceNumber(usize, usize), ContainerPadding(usize, usize, i32), WorkspacePadding(usize, usize, i32), WorkspaceTiling(usize, usize, bool), diff --git a/komorebi/src/process_command.rs b/komorebi/src/process_command.rs index c85d0ff9..8069c60f 100644 --- a/komorebi/src/process_command.rs +++ b/komorebi/src/process_command.rs @@ -220,6 +220,10 @@ impl WindowManager { self.focus_monitor(monitor_idx)?; self.focus_workspace(workspace_idx)?; } + SocketMessage::FocusMonitorWorkspaceNumber(monitor_idx, workspace_idx) => { + self.focus_monitor(monitor_idx)?; + self.focus_workspace(workspace_idx)?; + } SocketMessage::Stop => { tracing::info!( "received stop command, restoring all hidden windows and terminating process" diff --git a/komorebic.lib.sample.ahk b/komorebic.lib.sample.ahk index e5f80c9d..04f519c8 100644 --- a/komorebic.lib.sample.ahk +++ b/komorebic.lib.sample.ahk @@ -104,6 +104,10 @@ FocusWorkspace(target) { Run, komorebic.exe focus-workspace %target%, , Hide } +FocusMonitorWorkspace(target_monitor, target_workspace) { + Run, komorebic.exe focus-monitor-workspace %target_monitor% %target_workspace%, , Hide +} + CycleMonitor(cycle_direction) { Run, komorebic.exe cycle-monitor %cycle_direction%, , Hide } diff --git a/komorebic/src/main.rs b/komorebic/src/main.rs index d2f38088..83200e50 100644 --- a/komorebic/src/main.rs +++ b/komorebic/src/main.rs @@ -216,6 +216,14 @@ struct EnsureWorkspaces { workspace_count: usize, } +#[derive(Parser, AhkFunction)] +struct FocusMonitorWorkspace { + /// Target monitor index (zero-indexed) + target_monitor: usize, + /// Workspace index on the target monitor (zero-indexed) + target_workspace: usize, +} + macro_rules! gen_padding_subcommand_args { // SubCommand Pattern ( $( $name:ident ),+ $(,)? ) => { @@ -428,6 +436,9 @@ enum SubCommand { /// Focus the specified workspace on the focused monitor #[clap(setting = AppSettings::ArgRequiredElseHelp)] FocusWorkspace(FocusWorkspace), + /// Focus the specified workspace on the target monitor + #[clap(setting = AppSettings::ArgRequiredElseHelp)] + FocusMonitorWorkspace(FocusMonitorWorkspace), /// Focus the monitor in the given cycle direction #[clap(setting = AppSettings::ArgRequiredElseHelp)] CycleMonitor(CycleMonitor), @@ -797,6 +808,15 @@ fn main() -> Result<()> { SubCommand::FocusWorkspace(arg) => { send_message(&*SocketMessage::FocusWorkspaceNumber(arg.target).as_bytes()?)?; } + SubCommand::FocusMonitorWorkspace(arg) => { + send_message( + &*SocketMessage::FocusMonitorWorkspaceNumber( + arg.target_monitor, + arg.target_workspace, + ) + .as_bytes()?, + )?; + } SubCommand::CycleMonitor(arg) => { send_message(&*SocketMessage::CycleFocusMonitor(arg.cycle_direction).as_bytes()?)?; }