diff --git a/outfly.toml b/src/data/outfly.toml similarity index 100% rename from outfly.toml rename to src/data/outfly.toml diff --git a/src/var.rs b/src/var.rs index 868c0b1..b65f454 100644 --- a/src/var.rs +++ b/src/var.rs @@ -76,27 +76,32 @@ fn get_prefs_path() -> Option { } pub fn load_prefs() -> Preferences { - let prefs_path = match get_prefs_path() { - Some(path) => path, + let (toml, path) = match get_prefs_path() { + Some(path) => { + let toml = fs::read_to_string(&path); + match toml { + Ok(toml) => (toml, Some(path)), + Err(error) => { + error!("Failed to open preferences file '{path}': {error}"); + return Preferences::default(); + } + } + } None => { warn!("Found no preference file, using default preferences."); - return Preferences::default(); - } - }; - let toml = fs::read_to_string(&prefs_path); - let toml = match toml { - Ok(toml) => toml, - Err(error) => { - error!("Failed to open preferences file '{prefs_path}': {error}"); - return Preferences::default(); + (include_str!("data/outfly.toml").to_string(), None) } }; match toml.parse::() { Ok(doc) => { match toml_edit::de::from_document::(doc) { Ok(mut pref) => { - info!("Loaded preference file from {prefs_path}"); - pref.source_file = Some(prefs_path); + if let Some(path) = &path { + info!("Loaded preference file from {path}"); + } else { + info!("Loaded preferences from internal defaults"); + } + pref.source_file = path; dbg!(&pref); return pref; }