GlazeWM is a tiling window manager for macOS and Windows inspired by i3wm.
feat: add support for using env variable `GLAZEWM_CONFIG_PATH` for config path (#696)
Nikita Revenco5b5f68bce99c
diff --git a/README.md b/README.mdindex f5a5b73f..998db458 100644--- a/README.md+++ b/README.md@@ -66,6 +66,14 @@ To use a different config file location, you can launch the GlazeWM executable w./glazewm.exe start --config="C:\<PATH_TO_CONFIG>\config.yaml"```+Or pass a value for the `GLAZEWM_CONFIG_PATH` environment variable:++```sh+setx GLAZEWM_CONFIG_PATH "C:\<PATH_TO_CONFIG>\config.yaml"+```++With the benefit of using a custom path being that you can choose a different name for the config file, such as `glazewm.yaml`.+### Config: General```yamldiff --git a/packages/wm/src/user_config.rs b/packages/wm/src/user_config.rsindex 458b1440..4fced127 100644--- a/packages/wm/src/user_config.rs+++ b/packages/wm/src/user_config.rs@@ -1,4 +1,4 @@-use std::{collections::HashMap, fs, path::PathBuf};+use std::{collections::HashMap, fs, env, path::PathBuf};use anyhow::{Context, Result};use serde::{Deserialize, Serialize};@@ -42,7 +42,10 @@ impl UserConfig {.context("Unable to get home directory.")?.join(".glzr/glazewm/config.yaml");- let config_path = config_path.unwrap_or(default_config_path);+ let config_path = config_path+ .or_else(|| env::var("GLAZEWM_CONFIG_PATH").ok().map(PathBuf::from))+ .unwrap_or(default_config_path);+let (config_value, config_str) = Self::read(&config_path)?;let window_rules_by_event = Self::window_rules_by_event(&config_value);