summaryrefslogtreecommitdiff
path: root/src/config.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/config.rs')
-rw-r--r--src/config.rs48
1 files changed, 48 insertions, 0 deletions
diff --git a/src/config.rs b/src/config.rs
new file mode 100644
index 0000000..0be1d09
--- /dev/null
+++ b/src/config.rs
@@ -0,0 +1,48 @@
+use directories::{ProjectDirs, UserDirs};
+use serde::{Deserialize, Serialize};
+
+#[derive(Serialize, Deserialize)]
+pub struct Config {
+ pub music_roots: Vec<String>,
+ pub audio_exts: Vec<String>,
+ pub skip_window_secs: u64,
+ pub learning_rate: f32,
+ pub decay_rate: f32,
+ pub min_score_thresh: f32,
+ pub temperature: f32,
+}
+
+pub fn default_state_path() -> String {
+ ProjectDirs::from("qualifier", "organisation", "mood")
+ .and_then(|pd| {
+ pd.config_dir()
+ .join("mood.ron")
+ .to_str()
+ .map(|x| x.to_string())
+ })
+ .unwrap_or("~/.config/mood/mood.ron".to_string())
+}
+
+impl Default for Config {
+ fn default() -> Config {
+ Config {
+ music_roots: vec![
+ UserDirs::new()
+ .and_then(|u| {
+ u.audio_dir()
+ .and_then(|p| p.to_str().map(|x| x.to_string()))
+ })
+ .unwrap_or("~/Music".to_string()),
+ ],
+ audio_exts: [".mp3", ".flac", ".wav", ".m4a", ".ogg", ".vorbis"]
+ .into_iter()
+ .map(String::from)
+ .collect(),
+ skip_window_secs: 60,
+ learning_rate: 0.1,
+ decay_rate: 0.001,
+ min_score_thresh: 1e-5,
+ temperature: 0.6,
+ }
+ }
+}