diff --git a/src/main.rs b/src/main.rs index 54b7e00..6084208 100644 --- a/src/main.rs +++ b/src/main.rs @@ -47,7 +47,8 @@ usage: wldash [OPTIONS] OPTIONS: --config CONFIG_FILE use the specified config file - (~/.config/wldash/config.yml by default) + (/etc/wldash/config.yml if present, + else ~/.config/wldash/config.yml) --write-default-config [v1|v2|toplevel] generate and write a new config file (v2 by default) --desktop-refresh refresh desktop file cache @@ -69,6 +70,18 @@ fn create_required_directories() { ensure_dir_exists(&dir_cache_wldash); } +/// Default config path. On a shared (e.g. NFS-roamed) home, a host-specific +/// config at /etc/wldash/config.yml takes precedence over the roamed +/// ~/.config/wldash/config.yml, so each machine can keep its own layout +/// without conflicting. An explicit --config still overrides both. +fn default_config_file() -> String { + let etc = "/etc/wldash/config.yml"; + if Path::new(etc).exists() { + return etc.to_string(); + } + format!("{}/wldash/config.yml", xdg::config_folder()) +} + fn main() { let mut args = env::args(); // Skip program name @@ -76,7 +89,7 @@ fn main() { create_required_directories(); - let mut config_file = format!("{}/wldash/config.yml", xdg::config_folder()); + let mut config_file = default_config_file(); loop { match args.next() {