From 2a30f09bbdf80d5399dafd662513a8eb2e518c69 Mon Sep 17 00:00:00 2001 From: LGUG2Z Date: Mon, 31 Mar 2025 17:41:34 -0700 Subject: [PATCH] feat(cli): add version as state query variant This commit adds a new StateQuery::Version, which allows integrators to make decisions about how to handle different versions of komorebi's state schema based on the version of komorebi that is running on a user's machine. --- komorebi/src/core/mod.rs | 1 + komorebi/src/lib.rs | 2 ++ komorebi/src/main.rs | 4 +--- komorebi/src/process_command.rs | 2 ++ 4 files changed, 6 insertions(+), 3 deletions(-) diff --git a/komorebi/src/core/mod.rs b/komorebi/src/core/mod.rs index 131b9ef4..35d3bc68 100644 --- a/komorebi/src/core/mod.rs +++ b/komorebi/src/core/mod.rs @@ -329,6 +329,7 @@ pub enum StateQuery { FocusedContainerIndex, FocusedWindowIndex, FocusedWorkspaceName, + Version, } #[derive( diff --git a/komorebi/src/lib.rs b/komorebi/src/lib.rs index af392fbd..59c1fb38 100644 --- a/komorebi/src/lib.rs +++ b/komorebi/src/lib.rs @@ -239,6 +239,8 @@ pub static REMOVE_TITLEBARS: AtomicBool = AtomicBool::new(false); pub static SLOW_APPLICATION_COMPENSATION_TIME: AtomicU64 = AtomicU64::new(20); +shadow_rs::shadow!(build); + #[must_use] pub fn current_virtual_desktop() -> Option> { let hkcu = RegKey::predef(HKEY_CURRENT_USER); diff --git a/komorebi/src/main.rs b/komorebi/src/main.rs index b972cecc..8558d8ba 100644 --- a/komorebi/src/main.rs +++ b/komorebi/src/main.rs @@ -56,8 +56,6 @@ use komorebi::HOME_DIR; use komorebi::INITIAL_CONFIGURATION_LOADED; use komorebi::SESSION_ID; -shadow_rs::shadow!(build); - fn setup(log_level: LogLevel) -> Result<(WorkerGuard, WorkerGuard)> { if std::env::var("RUST_LIB_BACKTRACE").is_err() { std::env::set_var("RUST_LIB_BACKTRACE", "1"); @@ -165,7 +163,7 @@ enum LogLevel { } #[derive(Parser)] -#[clap(author, about, version = build::CLAP_LONG_VERSION)] +#[clap(author, about, version = komorebi::build::CLAP_LONG_VERSION)] struct Opts { /// Allow the use of komorebi's custom focus-follows-mouse implementation #[clap(short, long = "ffm")] diff --git a/komorebi/src/process_command.rs b/komorebi/src/process_command.rs index ac271929..311b8475 100644 --- a/komorebi/src/process_command.rs +++ b/komorebi/src/process_command.rs @@ -46,6 +46,7 @@ use crate::animation::ANIMATION_STYLE_GLOBAL; use crate::border_manager; use crate::border_manager::IMPLEMENTATION; use crate::border_manager::STYLE; +use crate::build; use crate::colour::Rgb; use crate::config_generation::WorkspaceMatchingRule; use crate::current_virtual_desktop; @@ -1377,6 +1378,7 @@ impl WindowManager { .focused_workspace_name() .unwrap_or_else(|| focused_monitor.focused_workspace_idx().to_string()) } + StateQuery::Version => build::RUST_VERSION.to_string(), }; reply.write_all(response.as_bytes())?;