From 270ea5aa46ec31fa1a18dc89445f3a4067e3cc90 Mon Sep 17 00:00:00 2001 From: LGUG2Z Date: Sun, 11 May 2025 18:23:35 -0700 Subject: [PATCH] feat(cli): add focused-container-kind state query This commit adds a new StateQuery variant, FocusedContainerKind, which will will return None if there is not focused container on the current workspace (ie. it is empty), Single if the focused container contains a single window, or Stack if the focused container contains more than one window. --- docs/cli/query.md | 2 +- docs/cli/toggle-shortcuts.md | 12 ++++++++++++ docs/cli/window-hiding-behaviour.md | 2 +- komorebi/src/core/mod.rs | 1 + komorebi/src/process_command.rs | 12 ++++++++++++ 5 files changed, 27 insertions(+), 2 deletions(-) create mode 100644 docs/cli/toggle-shortcuts.md diff --git a/docs/cli/query.md b/docs/cli/query.md index 0b377b73..25007d60 100644 --- a/docs/cli/query.md +++ b/docs/cli/query.md @@ -7,7 +7,7 @@ Usage: komorebic.exe query Arguments: - [possible values: focused-monitor-index, focused-workspace-index, focused-container-index, focused-window-index, focused-workspace-name, focused-workspace-layout, version] + [possible values: focused-monitor-index, focused-workspace-index, focused-container-index, focused-window-index, focused-workspace-name, focused-workspace-layout, focused-container-kind, version] Options: -h, --help diff --git a/docs/cli/toggle-shortcuts.md b/docs/cli/toggle-shortcuts.md new file mode 100644 index 00000000..fa80a20a --- /dev/null +++ b/docs/cli/toggle-shortcuts.md @@ -0,0 +1,12 @@ +# toggle-shortcuts + +``` +Toggle the komorebi-shortcuts helper + +Usage: komorebic.exe toggle-shortcuts + +Options: + -h, --help + Print help + +``` diff --git a/docs/cli/window-hiding-behaviour.md b/docs/cli/window-hiding-behaviour.md index 4ffc09ec..0aeea569 100644 --- a/docs/cli/window-hiding-behaviour.md +++ b/docs/cli/window-hiding-behaviour.md @@ -8,7 +8,7 @@ Usage: komorebic.exe window-hiding-behaviour Arguments: Possible values: - - hide: Use the SW_HIDE flag to hide windows when switching workspaces (has issues with Electron apps) + - hide: END OF LIFE FEATURE: Use the SW_HIDE flag to hide windows when switching workspaces (has issues with Electron apps) - minimize: Use the SW_MINIMIZE flag to hide windows when switching workspaces (has issues with frequent workspace switching) - cloak: Use the undocumented SetCloak Win32 function to hide windows when switching workspaces diff --git a/komorebi/src/core/mod.rs b/komorebi/src/core/mod.rs index faae3b08..30ce6673 100644 --- a/komorebi/src/core/mod.rs +++ b/komorebi/src/core/mod.rs @@ -341,6 +341,7 @@ pub enum StateQuery { FocusedWindowIndex, FocusedWorkspaceName, FocusedWorkspaceLayout, + FocusedContainerKind, Version, } diff --git a/komorebi/src/process_command.rs b/komorebi/src/process_command.rs index 7ec36f63..6a94c81e 100644 --- a/komorebi/src/process_command.rs +++ b/komorebi/src/process_command.rs @@ -1456,6 +1456,18 @@ impl WindowManager { }, ) } + StateQuery::FocusedContainerKind => { + match self.focused_workspace()?.focused_container() { + None => "None".to_string(), + Some(container) => { + if container.windows().len() > 1 { + "Stack".to_string() + } else { + "Single".to_string() + } + } + } + } }; reply.write_all(response.as_bytes())?;