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 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 4.8
parent
1156b3503a
commit
1367bd8591
+15
-2
@@ -47,7 +47,8 @@ usage: wldash [OPTIONS]
|
|||||||
|
|
||||||
OPTIONS:
|
OPTIONS:
|
||||||
--config CONFIG_FILE use the specified config file
|
--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
|
--write-default-config [v1|v2|toplevel] generate and write a new config file
|
||||||
(v2 by default)
|
(v2 by default)
|
||||||
--desktop-refresh refresh desktop file cache
|
--desktop-refresh refresh desktop file cache
|
||||||
@@ -69,6 +70,18 @@ fn create_required_directories() {
|
|||||||
ensure_dir_exists(&dir_cache_wldash);
|
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() {
|
fn main() {
|
||||||
let mut args = env::args();
|
let mut args = env::args();
|
||||||
// Skip program name
|
// Skip program name
|
||||||
@@ -76,7 +89,7 @@ fn main() {
|
|||||||
|
|
||||||
create_required_directories();
|
create_required_directories();
|
||||||
|
|
||||||
let mut config_file = format!("{}/wldash/config.yml", xdg::config_folder());
|
let mut config_file = default_config_file();
|
||||||
|
|
||||||
loop {
|
loop {
|
||||||
match args.next() {
|
match args.next() {
|
||||||
|
|||||||
Reference in New Issue
Block a user