Skip to content

Commit

Permalink
Prioritize YTUI_MUSIC_DIR env varibale over dirs::preferene_dir
Browse files Browse the repository at this point in the history
  • Loading branch information
sudipghimire533 committed Nov 20, 2021
1 parent 6c93c44 commit fba6569
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion config/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down Expand Up @@ -397,6 +397,13 @@ impl ConfigContainer {
}

pub fn get_config_dir() -> Option<path::PathBuf> {
// 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);
Expand Down

0 comments on commit fba6569

Please sign in to comment.