feat(clock): sound notification (experimental) (#62)

This commit is contained in:
Jens Krause
2025-02-04 17:28:41 +01:00
committed by GitHub
parent 8f50bc5fc6
commit a54b1b409a
10 changed files with 818 additions and 52 deletions

View File

@@ -1,8 +1,10 @@
use crate::{
common::{Content, Notification, Style},
duration,
duration, sound,
sound::SoundError,
};
use clap::Parser;
use std::path::PathBuf;
use std::time::Duration;
#[derive(Parser)]
@@ -45,4 +47,20 @@ pub struct Args {
help = "Toggle desktop notifications on or off. Experimental."
)]
pub notification: Option<Notification>,
#[arg(
long,
value_enum,
help = "Path to sound file (.mp3 or .wav) to play as notification. Experimental.",
value_hint = clap::ValueHint::FilePath,
value_parser = sound_file_parser,
)]
pub sound: Option<PathBuf>,
}
/// Custom parser for sound file
fn sound_file_parser(s: &str) -> Result<PathBuf, SoundError> {
let path = PathBuf::from(s);
sound::validate_sound_file(&path)?;
Ok(path)
}