From 08665bc83523344a6c9306bc8dc1917196b5a3ae Mon Sep 17 00:00:00 2001 From: lew Date: Thu, 2 Apr 2026 00:36:51 +0100 Subject: [PATCH] feat(sounds): _play_sound using pw-play, paplay, or aplay, if not muted and NAG_SOUND exists --- nag | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/nag b/nag index d82fc34..8a23166 100755 --- a/nag +++ b/nag @@ -372,6 +372,23 @@ _main() { # Global array holding raw TSV alarm lines (one element per alarm). _ALARMS=() +# Usage: +# _play_sound +# +# Description: +# Play the alarm sound if NAG_SOUND exists and not muted. +_play_sound() { + [[ -n "${NAG_SOUND}" ]] && [[ -f "${NAG_SOUND}" ]] && [[ ! -f "${_MUTED_FILE}" ]] || return 0 + + if _command_exists pw-play; then + pw-play "${NAG_SOUND}" & + elif _command_exists paplay; then + paplay "${NAG_SOUND}" & + elif _command_exists aplay; then + aplay "${NAG_SOUND}" & + fi +} + # Usage: # _ensure_nag_dir # @@ -1111,6 +1128,7 @@ check() { then # Fire it. ${NAG_CMD} "nag" "${_message}" || _warn printf "Failed to notify: %s\\n" "${_message}" + _play_sound if [[ -n "${_rule}" ]] then