flake install melody

This commit is contained in:
2005 2024-05-21 21:25:41 +02:00
parent bdd2e5def9
commit dce4e6284d
4 changed files with 17 additions and 10 deletions

View file

@ -26,6 +26,7 @@ Options:
- [ ] Styling
- [ ] Custom sounds (via .config)
- [x] Nix flake
- [ ] double digit counter for number below 10
# Develop

View file

@ -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
'';
};
});

1
result Symbolic link
View file

@ -0,0 +1 @@
/nix/store/pgv753ssnznv9hlapz6c2vnh6fmw9pgg-romodoro-0.1.1

View file

@ -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));
});