78 lines
1.7 KiB
Bash
Executable File
78 lines
1.7 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
|
|
change="$1"
|
|
|
|
if [ -z "$change" ]; then
|
|
echo "Usage: $0 [+5%|-5%|50%]"
|
|
exit 1
|
|
fi
|
|
|
|
echo "=== Deezer Volume Debug (FIXED) ==="
|
|
|
|
# 1) Deezer window PID
|
|
root_pid=$(hyprctl clients -j | jq -r '.[] | select(.class == "deezer-desktop") | .pid' | head -n1)
|
|
echo "[INFO] Deezer window PID: $root_pid"
|
|
|
|
if [ -z "$root_pid" ] || [ "$root_pid" = "null" ]; then
|
|
echo "[ERROR] Deezer window not found."
|
|
exit 1
|
|
fi
|
|
|
|
# 2) Gather ALL descendant PIDs
|
|
declare -a pid_array
|
|
pid_array+=("$root_pid")
|
|
|
|
# Direct children
|
|
children=($(pgrep -P "$root_pid"))
|
|
echo "[INFO] Children: ${children[*]}"
|
|
|
|
for c in "${children[@]}"; do
|
|
pid_array+=("$c")
|
|
gc=($(pgrep -P "$c"))
|
|
echo "[INFO] Grandchildren of $c: ${gc[*]}"
|
|
for g in "${gc[@]}"; do
|
|
pid_array+=("$g")
|
|
done
|
|
done
|
|
|
|
echo "[INFO] All collected PIDs: ${pid_array[*]}"
|
|
|
|
echo "----------------------------------"
|
|
echo "[INFO] Checking sink inputs..."
|
|
echo "----------------------------------"
|
|
|
|
sink=""
|
|
|
|
while IFS= read -r block; do
|
|
pid=$(echo "$block" | jq -r '.properties["application.process.id"] // empty')
|
|
index=$(echo "$block" | jq -r '.index')
|
|
|
|
echo "[SINK] index=$index pid=$pid"
|
|
|
|
[ -z "$pid" ] && { echo " -> Skipping"; continue; }
|
|
|
|
for candidate in "${pid_array[@]}"; do
|
|
if [ "$pid" = "$candidate" ]; then
|
|
echo " -> MATCH with PID $candidate"
|
|
sink="$index"
|
|
break 2
|
|
fi
|
|
done
|
|
|
|
echo " -> No match"
|
|
|
|
done < <(pactl -f json list sink-inputs | jq -c '.[]')
|
|
|
|
echo "----------------------------------"
|
|
|
|
if [ -z "$sink" ]; then
|
|
echo "[ERROR] No audio stream found for Deezer."
|
|
exit 1
|
|
fi
|
|
|
|
echo "[INFO] Deezer sink index: $sink"
|
|
echo "[INFO] Applying: $change"
|
|
|
|
pactl set-sink-input-volume "$sink" "$change"
|
|
|