From fba65693809ff7b12e88283e68c3c24c91323453 Mon Sep 17 00:00:00 2001 From: Sudip Ghimire Date: Sat, 20 Nov 2021 21:10:28 +0545 Subject: [PATCH] Prioritize YTUI_MUSIC_DIR env varibale over dirs::preferene_dir --- config/lib.rs | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/config/lib.rs b/config/lib.rs index f0a786d..e2e9093 100644 --- a/config/lib.rs +++ b/config/lib.rs @@ -274,7 +274,7 @@ pub struct MpvOptions { impl Default for MpvOptions { fn default() -> Self { MpvOptions { - config_path: ConfigContainer::get_preferences_dir() + config_path: ConfigContainer::get_config_dir() .unwrap() .as_path() .to_string_lossy() @@ -397,6 +397,13 @@ impl ConfigContainer { } pub fn get_config_dir() -> Option { + // If $YTUI_MUSIC_CONFIG_DIR env is set. Use it + if let Ok(val) = std::env::var("YTUI_MUSIC_CONFIG_DIR") { + eprintln!("YTUI_MUSIC_CONFIG_DIR environment variable is set. Using it..."); + let config_dir = path::PathBuf::from(val); + return Some(config_dir); + } + match dirs::preference_dir() { Some(mut config_dir) => { config_dir = config_dir.join(CONF_DIR_NAME);