flake install melody
This commit is contained in:
parent
bdd2e5def9
commit
dce4e6284d
|
@ -26,6 +26,7 @@ Options:
|
||||||
- [ ] Styling
|
- [ ] Styling
|
||||||
- [ ] Custom sounds (via .config)
|
- [ ] Custom sounds (via .config)
|
||||||
- [x] Nix flake
|
- [x] Nix flake
|
||||||
|
- [ ] double digit counter for number below 10
|
||||||
|
|
||||||
# Develop
|
# Develop
|
||||||
|
|
||||||
|
|
|
@ -29,7 +29,7 @@
|
||||||
{
|
{
|
||||||
default = pkgs.rustPlatform.buildRustPackage {
|
default = pkgs.rustPlatform.buildRustPackage {
|
||||||
pname = "romodoro";
|
pname = "romodoro";
|
||||||
version = "0.1.0";
|
version = "0.1.1";
|
||||||
src = ./.;
|
src = ./.;
|
||||||
|
|
||||||
nativeBuildInputs = [
|
nativeBuildInputs = [
|
||||||
|
@ -50,6 +50,11 @@
|
||||||
pkgs.cmake
|
pkgs.cmake
|
||||||
];
|
];
|
||||||
cargoLock.lockFile = ./Cargo.lock;
|
cargoLock.lockFile = ./Cargo.lock;
|
||||||
|
installPhase = ''
|
||||||
|
# copy the sound file
|
||||||
|
mkdir -p $out
|
||||||
|
cp $src/src/assets/melody.mp3 $out
|
||||||
|
'';
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
1
result
Symbolic link
1
result
Symbolic link
|
@ -0,0 +1 @@
|
||||||
|
/nix/store/pgv753ssnznv9hlapz6c2vnh6fmw9pgg-romodoro-0.1.1
|
18
src/app.rs
18
src/app.rs
|
@ -44,20 +44,20 @@ impl App {
|
||||||
}
|
}
|
||||||
pub fn tick(&mut self) {
|
pub fn tick(&mut self) {
|
||||||
// Notification logic...
|
// Notification logic...
|
||||||
// TODO add ticking sound for the 5 second cooldown
|
|
||||||
if self.current_time_left() <= 0 {
|
if self.current_time_left() <= 0 {
|
||||||
thread::spawn(|| {
|
thread::spawn( || {
|
||||||
let (_stream, stream_handle) = OutputStream::try_default().unwrap();
|
let (_stream, stream_handle) = OutputStream::try_default().unwrap();
|
||||||
// TODO add this to the app object instead of opening it every interval (ram)
|
// TODO add this to the app object instead of opening it every interval (ram)
|
||||||
let file = match File::open("./src/assets/melody.mp3") {
|
let file = match File::open("./melody.mp3") {
|
||||||
Ok(file) => file,
|
Ok(file) => {
|
||||||
Err(_) => File::open("~/.config/romodoro/assets/melody.mp3").unwrap(),
|
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
|
// FIXME increase the sleep based on the length of the sound
|
||||||
std::thread::sleep(std::time::Duration::from_secs(5));
|
std::thread::sleep(std::time::Duration::from_secs(5));
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in a new issue