diff --git a/README.md b/README.md index 61c24a8..12bab02 100644 --- a/README.md +++ b/README.md @@ -26,6 +26,7 @@ Options: - [ ] Styling - [ ] Custom sounds (via .config) - [x] Nix flake +- [ ] double digit counter for number below 10 # Develop diff --git a/flake.nix b/flake.nix index 89b41af..9937bdd 100644 --- a/flake.nix +++ b/flake.nix @@ -29,7 +29,7 @@ { default = pkgs.rustPlatform.buildRustPackage { pname = "romodoro"; - version = "0.1.0"; + version = "0.1.1"; src = ./.; nativeBuildInputs = [ @@ -50,6 +50,11 @@ pkgs.cmake ]; cargoLock.lockFile = ./Cargo.lock; + installPhase = '' + # copy the sound file + mkdir -p $out + cp $src/src/assets/melody.mp3 $out + ''; }; }); diff --git a/result b/result new file mode 120000 index 0000000..0df76cd --- /dev/null +++ b/result @@ -0,0 +1 @@ +/nix/store/pgv753ssnznv9hlapz6c2vnh6fmw9pgg-romodoro-0.1.1 \ No newline at end of file diff --git a/src/app.rs b/src/app.rs index dc9c7eb..af0f4ad 100644 --- a/src/app.rs +++ b/src/app.rs @@ -44,20 +44,20 @@ impl App { } pub fn tick(&mut self) { // Notification logic... - // TODO add ticking sound for the 5 second cooldown if self.current_time_left() <= 0 { - thread::spawn(|| { + thread::spawn( || { let (_stream, stream_handle) = OutputStream::try_default().unwrap(); // TODO add this to the app object instead of opening it every interval (ram) - let file = match File::open("./src/assets/melody.mp3") { - Ok(file) => file, - Err(_) => File::open("~/.config/romodoro/assets/melody.mp3").unwrap(), + let file = match File::open("./melody.mp3") { + Ok(file) => { + let file = BufReader::new(file); + let source = Decoder::new(file).unwrap(); + stream_handle.play_raw(source.convert_samples()); + }, + // if file is not found, just skip playing + Err(_) => (), }; - let file = BufReader::new(file); - let source = Decoder::new(file).unwrap(); - stream_handle.play_raw(source.convert_samples()); - // FIXME increase the sleep based on the length of the sound std::thread::sleep(std::time::Duration::from_secs(5)); });