feat(sounds): _play_sound using pw-play, paplay, or aplay, if not muted and NAG_SOUND exists
This commit is contained in:
parent
1390968eb2
commit
08665bc835
1 changed files with 18 additions and 0 deletions
18
nag
18
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
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue