Skip to content

GlazeWM is a tiling window manager for macOS and Windows inspired by i3wm.

feat: customize version number shown in cli & system tray

Lars Berger0323e00faf9d
diff --git a/.cargo/config.toml b/.cargo/config.toml
new file mode 100644
index 00000000..96806aff
--- /dev/null
+++ b/.cargo/config.toml
@@ -0,0 +1,4 @@
+[env]
+# Version number shown in CLI and system tray. Override this by setting the
+# version number on build/run (i.e. `VERSION_NUMBER="1.0.0" cargo run`).
+VERSION_NUMBER = "0.0.0"
diff --git a/packages/wm/src/app_command.rs b/packages/wm/src/app_command.rs
index 6414ca72..2ab830e2 100644
--- a/packages/wm/src/app_command.rs
+++ b/packages/wm/src/app_command.rs
@@ -35,8 +35,10 @@ use crate::{
},
};
+const VERSION: &'static str = env!("VERSION_NUMBER");
+
#[derive(Clone, Debug, Parser)]
-#[clap(author, version, about, long_about = None)]
+#[clap(author, version = VERSION, about, long_about = None)]
pub enum AppCommand {
/// Starts the window manager.
Start {
diff --git a/packages/wm/src/sys_tray.rs b/packages/wm/src/sys_tray.rs
index 16bc59f2..c6db01c2 100644
--- a/packages/wm/src/sys_tray.rs
+++ b/packages/wm/src/sys_tray.rs
@@ -58,7 +58,7 @@ impl SystemTray {
let icon = Icon::from_resource(IDI_ICON, None)?;
let _tray_icon = TrayIconBuilder::new()
.with_menu(Box::new(tray_menu))
- .with_tooltip(format!("GlazeWM v{}", env!("CARGO_PKG_VERSION")))
+ .with_tooltip(format!("GlazeWM v{}", env!("VERSION_NUMBER")))
.with_icon(icon)
.build()?;