Patch-Source: https://github.com/maximbaz/wluma/pull/45 -- From 287ca22e90e005bd4e9343b57d0e0ea666f2f930 Mon Sep 17 00:00:00 2001 From: Jakub Jirutka Date: Thu, 10 Feb 2022 23:57:14 +0100 Subject: [PATCH] Add support for system-level config in /etc/xdg/wluma/ --- README.md | 2 +- src/config/mod.rs | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index d2d8ae1..6bf2273 100644 --- a/README.md +++ b/README.md @@ -40,7 +40,7 @@ In order to access backlight devices, `wluma` must either run as `root`, or pref ## Configuration -The `config.toml` in repository represents default config values. To change them, copy the file into `$XDG_CONFIG_HOME/wluma/config.toml` and adjust as desired. +The `config.toml` in repository represents default config values. To change them, copy the file into `$XDG_CONFIG_HOME/wluma/config.toml` or `/etc/xdg/wluma/config.toml` (the former takes precedence over the latter) and adjust as desired. ### ALS diff --git a/src/config/mod.rs b/src/config/mod.rs index b8944b2..d515de7 100644 --- a/src/config/mod.rs +++ b/src/config/mod.rs @@ -14,6 +14,7 @@ pub fn load() -> Result> { fn parse() -> Result { let file_config = dirs::config_dir() .and_then(|config_dir| fs::read_to_string(&config_dir.join("wluma/config.toml")).ok()) + .or_else(|| fs::read_to_string("/etc/xdg/wluma/config.toml").ok()) .unwrap_or_else(|| include_str!("../../config.toml").to_string()); let parse_als_thresholds = |t: HashMap| -> HashMap {