From 1367bd8591eea2a33d41b017db8608a8d32b74b6 Mon Sep 17 00:00:00 2001 From: Bendik Aagaard Lynghaug Date: Wed, 16 Sep 2026 14:16:22 +0200 Subject: [PATCH] config: prefer machine-local /etc/wldash/config.yml when present On a shared (NFS-roamed) home, ~/.config/wldash/config.yml is identical on every machine. Prefer a host-specific /etc/wldash/config.yml when it exists so each machine can keep its own layout without conflicting; --config still overrides both. Enables the 'factor host-specific config to /etc' pattern for shared-home fleets. Co-Authored-By: Claude Opus 4.8 --- src/main.rs | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) 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() {