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.
151 lines
3.3 KiB
Bash
Executable File
151 lines
3.3 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
|
|
|
|
SOUND_DIR="$HOME/.config/hypr/sound"
|
|
PLAYER="play"
|
|
VOLUME="0.1"
|
|
|
|
declare -A SOUND_MAP=(
|
|
["workspace"]="futuristic-click.wav"
|
|
["activewindow"]="popup.wav"
|
|
["activelayout"]="popup.wav"
|
|
["fullscreen"]="fullscreen.wav"
|
|
["openwindow"]="open.mp3"
|
|
["closewindow"]="popup.wav"
|
|
["movewindow"]="popup.wav"
|
|
["changefloatingmode"]="float.wav"
|
|
)
|
|
|
|
declare -A EVENT_ENABLED=(
|
|
["workspace"]=1
|
|
["activewindow"]=1
|
|
["activelayout"]=0
|
|
["fullscreen"]=1
|
|
["openwindow"]=1
|
|
["closewindow"]=1
|
|
["movewindow"]=1
|
|
["changefloatingmode"]=1
|
|
)
|
|
|
|
declare -A EVENT_COOLDOWN=(
|
|
["activewindow"]=0.1
|
|
["movewindow"]=0.2
|
|
["changefloatingmode"]=0.3
|
|
)
|
|
|
|
DEBUG=1
|
|
declare -a SOUND_QUEUE=()
|
|
declare -A COOLDOWN_TIMERS=()
|
|
|
|
mkdir -p "$SOUND_DIR"
|
|
|
|
log() {
|
|
if [ $DEBUG -eq 1 ]; then
|
|
echo "[$(date '+%H:%M:%S')] $1" >&2
|
|
fi
|
|
}
|
|
|
|
play_sound() {
|
|
local event="$1"
|
|
local sound_file="$2"
|
|
local full_path="$SOUND_DIR/$sound_file"
|
|
|
|
if [ ! -f "$full_path" ]; then
|
|
log "Sound file not found: $full_path"
|
|
return 1
|
|
fi
|
|
|
|
log "Playing: $event -> $sound_file"
|
|
|
|
play -v $VOLUME "$full_path" &
|
|
|
|
return 0
|
|
}
|
|
|
|
handle_event() {
|
|
local raw_event="$1"
|
|
local event_type=""
|
|
local event_data=""
|
|
|
|
if [[ "$raw_event" == *">>"* ]]; then
|
|
event_type="${raw_event%%>>*}"
|
|
event_data="${raw_event#*>>}"
|
|
else
|
|
event_type="$raw_event"
|
|
fi
|
|
|
|
log "Received event: $event_type (data: $event_data)"
|
|
|
|
case "$event_type" in
|
|
"workspace"*)
|
|
if [[ "$event_data" == *,* ]]; then
|
|
trigger_event "workspace" "$event_data"
|
|
fi
|
|
;;
|
|
"activelayout"*)
|
|
trigger_event "activelayout" "$event_data"
|
|
;;
|
|
"fullscreen"*)
|
|
trigger_event "fullscreen" "$event_data"
|
|
;;
|
|
"openwindow"*)
|
|
trigger_event "openwindow" "$event_data"
|
|
;;
|
|
"closewindow"*)
|
|
trigger_event "closewindow" "$event_data"
|
|
;;
|
|
"movewindow"*)
|
|
if [[ "$event_data" == *,*,* ]]; then
|
|
trigger_event "movewindow" "$event_data"
|
|
fi
|
|
;;
|
|
"changefloating"*)
|
|
trigger_event "changefloatingmode" "$event_data"
|
|
;;
|
|
*)
|
|
log "Unknown event: $event_type"
|
|
;;
|
|
esac
|
|
}
|
|
|
|
trigger_event() {
|
|
local event="$1"
|
|
local data="$2"
|
|
|
|
if [ "${EVENT_ENABLED[$event]:-0}" -ne 1 ]; then
|
|
log "Event $event is disabled"
|
|
return
|
|
fi
|
|
|
|
local sound_file="${SOUND_MAP[$event]}"
|
|
|
|
if [ -z "$sound_file" ]; then
|
|
log "No sound mapped for event: $event"
|
|
return
|
|
fi
|
|
|
|
if [ "$event" = "changefloatingmode" ]; then
|
|
local state="${data#*,}"
|
|
if [ "$state" -eq 1 ]; then
|
|
sound_file="float.wav"
|
|
else
|
|
sound_file="tile.wav"
|
|
fi
|
|
fi
|
|
|
|
play_sound "$event" "$sound_file"
|
|
}
|
|
|
|
echo "Sound directory: $SOUND_DIR"
|
|
echo "Enabled events:"
|
|
for event in "${!EVENT_ENABLED[@]}"; do
|
|
if [ "${EVENT_ENABLED[$event]}" -eq 1 ]; then
|
|
echo " - $event: ${SOUND_MAP[$event]}"
|
|
fi
|
|
done
|
|
|
|
socat - "UNIX-CONNECT:$XDG_RUNTIME_DIR/hypr/$HYPRLAND_INSTANCE_SIGNATURE/.socket2.sock" | \
|
|
while read -r line; do
|
|
handle_event "$line"
|
|
done
|