diff --git a/swaync/config.json b/swaync/config.json index 8d63fdd..1721c57 100644 --- a/swaync/config.json +++ b/swaync/config.json @@ -33,14 +33,9 @@ "text-empty": "No nothing", "script-fail-notify": true, "scripts": { - "example-script": { - "exec": "echo 'Do something...'", - "urgency": "Normal" - }, - "example-action-script": { - "exec": "echo 'Do something actionable!'", - "urgency": "Normal", - "run-on": "action" + "notification-sound": { + "exec": "sh $HOME/.config/swaync/scripts/sound.sh", + "app-name": "^(?!.*AyuGram).*$" } }, "notification-visibility": { diff --git a/swaync/scripts/sound.sh b/swaync/scripts/sound.sh new file mode 100755 index 0000000..c655193 --- /dev/null +++ b/swaync/scripts/sound.sh @@ -0,0 +1,33 @@ +#!/bin/bash + +if [ $(swaync-client --get-dnd) == "true" ]; then + echo "Do Not Disturb is on, skipping sound" + exit 0 +fi + +# Directory containing your notification sounds +SOUND_DIR="$HOME/.config/swaync/scripts/sounds" + +# Enable nullglob to prevent literal interpretation when no files match +shopt -s nullglob + +# Get a list of audio files in the directory (simpler approach) +SOUND_FILES=() +for ext in wav mp3 ogg flac; do + SOUND_FILES+=("$SOUND_DIR"/*."$ext") +done + +# Check if any sound files exist +if [ ${#SOUND_FILES[@]} -eq 0 ]; then + echo "No sound files found in $SOUND_DIR" + exit 0 # Exit with success so notifications still work +fi + +# Select a random sound file +RANDOM_INDEX=$((RANDOM % ${#SOUND_FILES[@]})) +RANDOM_SOUND="${SOUND_FILES[$RANDOM_INDEX]}" + +# Play the random sound +play -v 0.5 "$RANDOM_SOUND" 2>/dev/null || { + echo "Failed to play $RANDOM_SOUND" +} diff --git a/swaync/scripts/sounds/sting_instruction1.wav b/swaync/scripts/sounds/sting_instruction1.wav new file mode 100644 index 0000000..ca18d88 Binary files /dev/null and b/swaync/scripts/sounds/sting_instruction1.wav differ diff --git a/swaync/scripts/sounds/sting_instruction2.wav b/swaync/scripts/sounds/sting_instruction2.wav new file mode 100644 index 0000000..3874cc1 Binary files /dev/null and b/swaync/scripts/sounds/sting_instruction2.wav differ