feat(sounds): mute and unmute subcommands
This commit is contained in:
parent
08665bc835
commit
76768e4075
2 changed files with 57 additions and 0 deletions
34
nag
34
nag
|
|
@ -1252,5 +1252,39 @@ every() {
|
|||
printf "[%s] %s (%s) — %s\\n" "${_id}" "${_human_time}" "${_rules_str//,/, }" "${_message}"
|
||||
}
|
||||
|
||||
# mute ########################################################################
|
||||
|
||||
describe "mute" <<HEREDOC
|
||||
Usage:
|
||||
${_ME} mute
|
||||
|
||||
Description:
|
||||
Mute alarm sounds. Notifications still fire, but no sound is played.
|
||||
HEREDOC
|
||||
mute() {
|
||||
_ensure_nag_dir
|
||||
: > "${_MUTED_FILE}"
|
||||
printf "Sound muted.\\n"
|
||||
}
|
||||
|
||||
# unmute ######################################################################
|
||||
|
||||
describe "unmute" <<HEREDOC
|
||||
Usage:
|
||||
${_ME} unmute
|
||||
|
||||
Description:
|
||||
Unmute alarm sounds.
|
||||
HEREDOC
|
||||
unmute() {
|
||||
if [[ -f "${_MUTED_FILE}" ]]
|
||||
then
|
||||
rm -f "${_MUTED_FILE}"
|
||||
printf "Sound unmuted.\\n"
|
||||
else
|
||||
printf "Sound is not muted.\\n"
|
||||
fi
|
||||
}
|
||||
|
||||
# _main must be called after everything has been defined.
|
||||
_main
|
||||
|
|
|
|||
|
|
@ -304,3 +304,26 @@ SCRIPT
|
|||
[[ "${output}" =~ "Usage:" ]]
|
||||
[[ "${output}" =~ "check" ]]
|
||||
}
|
||||
|
||||
# mute/unmute #################################################################
|
||||
|
||||
@test "mute creates muted file" {
|
||||
run_nag mute
|
||||
[ "${status}" -eq 0 ]
|
||||
[[ "${output}" =~ "muted" ]]
|
||||
[ -f "${NAG_DIR}/muted" ]
|
||||
}
|
||||
|
||||
@test "unmute removes muted file" {
|
||||
run_nag mute
|
||||
run_nag unmute
|
||||
[ "${status}" -eq 0 ]
|
||||
[[ "${output}" =~ "unmuted" ]]
|
||||
[ ! -f "${NAG_DIR}/muted" ]
|
||||
}
|
||||
|
||||
@test "unmute when not muted says so" {
|
||||
run_nag unmute
|
||||
[ "${status}" -eq 0 ]
|
||||
[[ "${output}" =~ "not muted" ]]
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue