feat(sounds): _play_sound using pw-play, paplay, or aplay, if not muted and NAG_SOUND exists

This commit is contained in:
Lewis Wynne 2026-04-02 00:36:51 +01:00
parent 1390968eb2
commit 08665bc835

18
nag
View file

@ -372,6 +372,23 @@ _main() {
# Global array holding raw TSV alarm lines (one element per alarm). # Global array holding raw TSV alarm lines (one element per alarm).
_ALARMS=() _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: # Usage:
# _ensure_nag_dir # _ensure_nag_dir
# #
@ -1111,6 +1128,7 @@ check() {
then then
# Fire it. # Fire it.
${NAG_CMD} "nag" "${_message}" || _warn printf "Failed to notify: %s\\n" "${_message}" ${NAG_CMD} "nag" "${_message}" || _warn printf "Failed to notify: %s\\n" "${_message}"
_play_sound
if [[ -n "${_rule}" ]] if [[ -n "${_rule}" ]]
then then