From ad4e9e0055028fa27c815c7d9712a31453ec6df4 Mon Sep 17 00:00:00 2001 From: DragonSlayer_14 Date: Thu, 21 Aug 2025 00:44:10 +0200 Subject: [PATCH] =?UTF-8?q?Feat:=20L=C3=A4dt=20Konfigurationsdatei=20aus?= =?UTF-8?q?=20systemweitem=20Pfad,=20wenn=20Programm=20als=20Root=20ausgef?= =?UTF-8?q?=C3=BChrt=20wird?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/config.rs | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/config.rs b/src/config.rs index ff391a5..5ba7775 100644 --- a/src/config.rs +++ b/src/config.rs @@ -5,6 +5,7 @@ //! und beim Programmstart automatisch geladen. use crate::program; +use crate::sudo::is_run_as_root; use serde::{Deserialize, Serialize}; use std::sync::OnceLock; @@ -128,10 +129,19 @@ pub fn get_config() -> &'static AppConfig { /// Lädt die Konfiguration aus der Konfigurationsdatei. fn load_config() -> AppConfig { + #[cfg(target_os = "linux")] + if is_run_as_root() { + return confy::load_path(format!("/etc/{}/{}.toml", program::program_name(), CONFIG_NAME)).unwrap_or_default(); + } confy::load(&*program::program_name(), CONFIG_NAME).unwrap_or_default() } // /// Speichert die übergebene Konfiguration in der Konfigurationsdatei. // fn save_config(config: AppConfig) { +// #[cfg(target_os = "linux")] +// if is_run_as_root() { +// confy::store_path(format!("/etc/{}/{}.toml", program::program_name(), CONFIG_NAME), config).unwrap(); +// return; +// } // confy::store(&*program::program_name(), CONFIG_NAME, config).unwrap(); // } \ No newline at end of file