GlazeWM is a tiling window manager for macOS and Windows inspired by i3wm.
feat: add `startup_commands` option
Lars Berger52b9ee9c8071
diff --git a/packages/wm/src/app_command.rs b/packages/wm/src/app_command.rsindex e8e7de78..7693be2a 100644--- a/packages/wm/src/app_command.rs+++ b/packages/wm/src/app_command.rs@@ -133,18 +133,18 @@ impl Verbosity {#[derive(Clone, Debug, Parser)]pub enum QueryCommand {- /// Outputs all windows.- Windows,- /// Outputs all active workspaces.- Workspaces,- /// Outputs all monitors.- Monitors,+ /// Outputs metadata about the application (e.g. version number).+ AppMetadata,/// Outputs the active binding modes.BindingModes,/// Outputs the focused container (either a window or an empty workspace).Focused,- /// Outputs metadata about the application (e.g. version number).- AppMetadata,+ /// Outputs all monitors.+ Monitors,+ /// Outputs all windows.+ Windows,+ /// Outputs all active workspaces.+ Workspaces,}#[derive(Clone, Debug, PartialEq, ValueEnum)]@@ -155,8 +155,8 @@ pub enum SubscribableEvent {FocusChanged,FocusedContainerMoved,MonitorAdded,- MonitorUpdated,MonitorRemoved,+ MonitorUpdated,TilingDirectionChanged,UserConfigChanged,WindowManaged,diff --git a/packages/wm/src/main.rs b/packages/wm/src/main.rsindex a6b4acad..cf33426e 100644--- a/packages/wm/src/main.rs+++ b/packages/wm/src/main.rs@@ -92,6 +92,10 @@ async fn start_wm(// Start listening for platform events.let mut event_listener = Platform::start_event_listener(&config)?;+ // Run startup commands.+ let startup_commands = config.value.general.startup_commands.clone();+ wm.process_commands(startup_commands, None, &mut config)?;+loop {tokio::select! {Some(event) = event_listener.event_rx.recv() => {diff --git a/packages/wm/src/user_config.rs b/packages/wm/src/user_config.rsindex 41f0ddf6..cb7c84fb 100644--- a/packages/wm/src/user_config.rs+++ b/packages/wm/src/user_config.rs@@ -140,10 +140,10 @@ impl UserConfig {#[serde(rename_all(serialize = "camelCase"))]pub struct ParsedConfig {pub binding_modes: Vec<BindingModeConfig>,- pub window_effects: WindowEffectsConfig,pub gaps: GapsConfig,pub general: GeneralConfig,pub keybindings: Vec<KeybindingConfig>,+ pub window_effects: WindowEffectsConfig,pub window_rules: Vec<WindowRuleConfig>,pub window_state_defaults: WindowStateDefaultsConfig,pub workspaces: Vec<WorkspaceConfig>,@@ -162,24 +162,6 @@ pub struct BindingModeConfig {pub keybindings: Vec<KeybindingConfig>,}-#[derive(Clone, Debug, Deserialize, Serialize)]-#[serde(rename_all(serialize = "camelCase"))]-pub struct WindowEffectsConfig {- /// Visual effects to apply to the focused window.- pub focused_window: WindowEffectConfig,-- /// Visual effects to apply to non-focused windows.- pub other_windows: WindowEffectConfig,-}--#[derive(Clone, Debug, Deserialize, Serialize)]-#[serde(rename_all(serialize = "camelCase"))]-pub struct WindowEffectConfig {- /// Optional colored border to apply.- #[serde(deserialize_with = "deserialize_option_color")]- pub border_color: Option<Color>,-}-#[derive(Clone, Debug, Deserialize, Serialize)]#[serde(rename_all(serialize = "camelCase"))]pub struct GapsConfig {@@ -207,6 +189,10 @@ pub struct GeneralConfig {/// focused workspace is activated.#[serde(default = "default_bool::<true>")]pub toggle_workspace_on_refocus: bool,++ /// WM commands to run once on startup.+ #[serde(default)]+ pub startup_commands: Vec<InvokeCommand>,}#[derive(Clone, Debug, Deserialize, Serialize)]@@ -219,6 +205,24 @@ pub struct KeybindingConfig {pub commands: Vec<InvokeCommand>,}+#[derive(Clone, Debug, Deserialize, Serialize)]+#[serde(rename_all(serialize = "camelCase"))]+pub struct WindowEffectsConfig {+ /// Visual effects to apply to the focused window.+ pub focused_window: WindowEffectConfig,++ /// Visual effects to apply to non-focused windows.+ pub other_windows: WindowEffectConfig,+}++#[derive(Clone, Debug, Deserialize, Serialize)]+#[serde(rename_all(serialize = "camelCase"))]+pub struct WindowEffectConfig {+ /// Optional colored border to apply.+ #[serde(deserialize_with = "deserialize_option_color")]+ pub border_color: Option<Color>,+}+#[derive(Clone, Debug, Deserialize, Serialize)]#[serde(rename_all(serialize = "camelCase"))]pub struct WindowRuleConfig {diff --git a/resources/sample-config.yaml b/resources/sample-config.yamlindex 82e4f858..fc17258f 100644--- a/resources/sample-config.yaml+++ b/resources/sample-config.yaml@@ -9,6 +9,9 @@ general:# workspace when focusing the current workspace.toggle_workspace_on_refocus: true+ # Commands to run once when the WM has started.+ startup_commands: []+gaps:# Gap between adjacent windows.inner_gap: '20px'