Files
dotfiles/swaync/scripts/sound.sh
Nikolai Papin f30e7d0085 feat: add hyprland sound system with event-triggered audio feedback;
feat: implement new hyprland plugins (hyprfocus, hyprbars, dynamic-cursors);
refactor: reorganize hyprland autostart with delay staging and plugin configuration;
feat: add notification urgency-based sound system to swaync;
feat: enhance waybar with battery module, mpd controls, and dock bar;
refactor: update waybar taskbar with active window indicators and sorting;
feat: add hyprland shutdown sound and login audio greeting;
fix: adjust cava sleep timer and mpd sticker database configuration;
feat: update rmpc keybindings for improved playlist management;
fix: modify rofi keybindings for better navigation;
chore: add zsh aliases and misspell corrections;
refactor: update styling across swaync, waybar, and hyprland with new border radii and accent colors.
2025-12-29 20:47:57 +03:00

47 lines
1.0 KiB
Bash
Executable File

#!/bin/bash
if [ $(swaync-client --get-dnd) == "true" ]; then
echo "Do Not Disturb is on, skipping sound"
exit 0
fi
SOUND_LOW_DIR="$HOME/.config/swaync/scripts/sounds/low"
SOUND_NORMAL_DIR="$HOME/.config/swaync/scripts/sounds/normal"
SOUND_CRITICAL_DIR="$HOME/.config/swaync/scripts/sounds/critical"
case $1 in
low)
DIR=$SOUND_LOW_DIR
;;
normal)
DIR=$SOUND_NORMAL_DIR
;;
critical)
DIR=$SOUND_CRITICAL_DIR
;;
*)
echo "Unknown urgency level '$1'"
exit 1
;;
esac
# Enable nullglob to prevent literal interpretation when no files match
shopt -s nullglob
SOUND_FILES=()
for ext in wav mp3 ogg flac; do
SOUND_FILES+=("$DIR"/*."$ext")
done
if [ ${#SOUND_FILES[@]} -eq 0 ]; then
echo "No sound files found in $SOUND_NORMAL_DIR"
exit 0
fi
RANDOM_INDEX=$((RANDOM % ${#SOUND_FILES[@]}))
RANDOM_SOUND="${SOUND_FILES[$RANDOM_INDEX]}"
play -v 0.5 "$RANDOM_SOUND" 2>/dev/null || {
echo "Failed to play $RANDOM_SOUND"
}