use std::process::Command; mod config; mod learner; mod state; mod trajectory; use crate::{config::default_state_path, state::State}; fn mpc_load_and_play(path: &str) { _ = Command::new("mpc") .arg("clear") .output() .expect("failed to execute mpc clear"); _ = Command::new("mpc") .args(["add", path]) .output() .expect("failed to execute mpc add"); _ = Command::new("mpc") .arg("play") .output() .expect("failed to execute mpc play"); } fn notify(text: &str) { if let Err(e) = Command::new("notify-send") .args(["-t", "5000", "-a", "mood", &text]) .status() { eprintln!("Failed to show notification: {e}"); } } fn main() { let state = State::load(&default_state_path()); let mut state = match state { Err(e) => { eprintln!("Failed to load state: {e}"); State::default() } Ok(s) => s, }; let ur = state.update_albums(); println!("Update result: {ur}"); if let Some((next_album, prob)) = state.next() { let text = format!("Now playing: {next_album} ({:.2}%)", prob * 100.0); println!("{text}"); mpc_load_and_play(&next_album); notify(&text); } else { println!("No next album available."); } if let Err(e) = state.try_save() { eprintln!("Failed to save state: {e}"); } }