diff --git a/src/utils/config.rs b/src/utils/config.rs index 61c24af..9dfc94b 100644 --- a/src/utils/config.rs +++ b/src/utils/config.rs @@ -5,13 +5,26 @@ use toml::Table; use crate::{utils::macros::ErrorLevel, write_log_to_file, ERROR}; -pub static mut CONFIG_STRING: &str = "~/reset/ReSet.toml"; +pub static mut CONFIG_STRING: Lazy = Lazy::new(|| { + let base = directories_next::ProjectDirs::from("org", "Xetibo", "ReSet"); + if let Some(base) = base { + return base + .config_dir() + .join("ReSet.toml") + .to_str() + .unwrap() + .to_string(); + } else { + ERROR!("Failed to get user home", ErrorLevel::Critical); + } + String::from("") +}); #[allow(clippy::declare_interior_mutable_const)] pub const CONFIG: Lazy = Lazy::new(parse_config); pub fn parse_config() -> Table { unsafe { - let config_file = fs::File::open(CONFIG_STRING); + let config_file = fs::File::open(CONFIG_STRING.as_str()); if config_file.is_err() { ERROR!("Could not write config file", ErrorLevel::Recoverable); return Table::new();