aboutsummaryrefslogtreecommitdiff
path: root/src/sound.rs
diff options
context:
space:
mode:
authorOgulcan Celik <ogulcancelik@gmail.com>2026-05-11 16:39:24 +0300
committerOgulcan Celik <ogulcancelik@gmail.com>2026-05-11 16:39:24 +0300
commit9663028a82aeef9722adaac34d2fcb8c19fc3a53 (patch)
tree9a3b527c669d60868cd42540cf9a56827d230d09 /src/sound.rs
parent55cdf2e8f8af2dd3feebb4bb7d44c9cb7e23b384 (diff)
test: disable real sound playback during checks
Diffstat (limited to 'src/sound.rs')
-rw-r--r--src/sound.rs10
1 files changed, 10 insertions, 0 deletions
diff --git a/src/sound.rs b/src/sound.rs
index a156349b..12b127bb 100644
--- a/src/sound.rs
+++ b/src/sound.rs
@@ -9,6 +9,8 @@ use std::process::{Command, Output};
use tracing::warn;
+const DISABLE_SOUND_ENV: &str = "HERDR_DISABLE_SOUND";
+
static SOUND_DONE: &[u8] = include_bytes!("../assets/sounds/done.mp3");
static SOUND_REQUEST: &[u8] = include_bytes!("../assets/sounds/request.mp3");
@@ -24,6 +26,10 @@ pub enum Sound {
/// Play a notification sound in a background thread.
/// Silently does nothing if no audio player is available.
pub fn play(sound: Sound, config: &crate::config::SoundConfig) {
+ if sound_playback_disabled_by_env() {
+ return;
+ }
+
let custom_path = config.path_for(sound);
std::thread::spawn(move || {
if let Some(path) = custom_path {
@@ -46,6 +52,10 @@ pub fn play(sound: Sound, config: &crate::config::SoundConfig) {
});
}
+fn sound_playback_disabled_by_env() -> bool {
+ std::env::var_os(DISABLE_SOUND_ENV).is_some() || std::env::var_os("NEXTEST").is_some()
+}
+
fn play_file(path: &Path) -> Result<(), String> {
match run_player(path) {
Ok(output) if output.status.success() => Ok(()),