feat: random notification sounds
This commit is contained in:
@@ -33,14 +33,9 @@
|
|||||||
"text-empty": "No nothing",
|
"text-empty": "No nothing",
|
||||||
"script-fail-notify": true,
|
"script-fail-notify": true,
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"example-script": {
|
"notification-sound": {
|
||||||
"exec": "echo 'Do something...'",
|
"exec": "sh $HOME/.config/swaync/scripts/sound.sh",
|
||||||
"urgency": "Normal"
|
"app-name": "^(?!.*AyuGram).*$"
|
||||||
},
|
|
||||||
"example-action-script": {
|
|
||||||
"exec": "echo 'Do something actionable!'",
|
|
||||||
"urgency": "Normal",
|
|
||||||
"run-on": "action"
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"notification-visibility": {
|
"notification-visibility": {
|
||||||
|
|||||||
33
swaync/scripts/sound.sh
Executable file
33
swaync/scripts/sound.sh
Executable file
@@ -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"
|
||||||
|
}
|
||||||
BIN
swaync/scripts/sounds/sting_instruction1.wav
Normal file
BIN
swaync/scripts/sounds/sting_instruction1.wav
Normal file
Binary file not shown.
BIN
swaync/scripts/sounds/sting_instruction2.wav
Normal file
BIN
swaync/scripts/sounds/sting_instruction2.wav
Normal file
Binary file not shown.
Reference in New Issue
Block a user