remove sound from notifications

This commit is contained in:
thomasabishop 2025-04-06 16:06:10 +01:00
parent 1d944cc6ec
commit bbbf25a70e
2 changed files with 13 additions and 12 deletions

View file

@ -5,16 +5,17 @@
# Parameters # Parameters
# --- $1 = Time schedule ('hourly' | 'daily' | 'weekly' | 'monthly') # --- $1 = Time schedule ('hourly' | 'daily' | 'weekly' | 'monthly')
#USER=thomas USER=thomas
#export XDG_RUNTIME_DIR=/run/user/1000 export HOME=/home/thomas
#source /home/thomas/.env export XDG_RUNTIME_DIR=/run/user/1000
source /home/thomas/.env
SCHEDULE=$1 SCHEDULE=$1
THIS_FILE=${0} THIS_FILE=${0}
SLACK_NOTIFIER="${HOME}/repos/utilities/slack_notifier.sh" SLACK_NOTIFIER="${HOME}/repos/utilities/slack_notifier.sh"
if mountpoint -q /media/samsung-T3; then if mountpoint -q /media/samsung-T3; then
ERROR=$(sudo /usr/bin/rsnapshot -c /etc/rsnapshot.conf hourly 2>&1) ERROR=$(sudo /usr/bin/rsnapshot -c /etc/rsnapshot.conf "$SCHEDULE" 2>&1)
STATUS=$? STATUS=$?
if [ $STATUS -ne 0 ]; then if [ $STATUS -ne 0 ]; then
$SLACK_NOTIFIER "backups" "error" "${SCHEDULE} /home backup failed" "$ERROR" "$THIS_FILE" $SLACK_NOTIFIER "backups" "error" "${SCHEDULE} /home backup failed" "$ERROR" "$THIS_FILE"

View file

@ -1,6 +1,6 @@
#!/bin/bash #!/bin/bash
# Send error and success notifications to Slack channels and play sound # Send error and success notifications to Slack channels
# Env vars: # Env vars:
# --- Webhook URLs for given channel, eg $SLACK_WEBHOOK_TEST, $SLACK_WEBHOOK_EOLAS # --- Webhook URLs for given channel, eg $SLACK_WEBHOOK_TEST, $SLACK_WEBHOOK_EOLAS
@ -64,9 +64,9 @@ ERROR_BLOCKS=$(
# Initialise sound playback # Initialise sound playback
mpv --volume=0 --start=0 --length=0.1 "${HOME}/dotfiles/sounds/star-trek-computer-success.mp3" \ # mpv --volume=0 --start=0 --length=0.1 "${HOME}/dotfiles/sounds/star-trek-computer-success.mp3" \
>/dev/null 2>&1 # >/dev/null 2>&1
sleep 1 # sleep 1
# Process notification # Process notification
if [ "$2" != "error" ]; then if [ "$2" != "error" ]; then
@ -74,14 +74,14 @@ if [ "$2" != "error" ]; then
-H 'Content-type: application/json' \ -H 'Content-type: application/json' \
--data '{"text":"🟢 '"$3"'"}' \ --data '{"text":"🟢 '"$3"'"}' \
"$WEBHOOK" "$WEBHOOK"
mpv --volume=100 "${HOME}/dotfiles/sounds/star-trek-computer-success.mp3" \ # mpv --volume=100 "${HOME}/dotfiles/sounds/star-trek-computer-success.mp3" \
>/dev/null 2>&1 >/dev/null 2>&1
else else
curl -X POST \ curl -X POST \
-H 'Content-type: application/json' \ -H 'Content-type: application/json' \
--json "$ERROR_BLOCKS" \ --json "$ERROR_BLOCKS" \
"$WEBHOOK" "$WEBHOOK"
mpv --volume=100 "${HOME}/dotfiles/sounds/star-trek-computer-error.mp3" \ # mpv --volume=100 "${HOME}/dotfiles/sounds/star-trek-computer-error.mp3" \
>/dev/null 2>&1 >/dev/null 2>&1
fi fi