update conf

This commit is contained in:
Johannes Knopp
2026-06-16 17:45:49 +02:00
parent a7aa1b2237
commit 48b73c40e9
10 changed files with 155 additions and 105 deletions

View File

@ -0,0 +1,95 @@
#!/usr/bin/env bash
action="$1"
if [ -z "$action" ]; then
echo "Usage: $0 [play-pause|next|previous|+5%|-5%|50%]"
exit 1
fi
# Deezer PWA PID
root_pid=$(hyprctl clients -j | jq -r '.[] | select(.initialTitle == "Deezer") | .pid' | head -n1)
if [ -z "$root_pid" ] || [ "$root_pid" = "null" ]; then
echo "[ERROR] Deezer window not found."
exit 1
fi
case "$action" in
play-pause|next|previous)
playerctl --player="chromium.instance${root_pid}" "$action"
exit 0
;;
*)
# Volume: find sink-input whose PID is in the process tree
pids=$(pstree -p "$root_pid" | grep -oP '\(\K[0-9]+')
sink=$(pactl -f json list sink-inputs | jq -r --argjson pids "$(echo "$pids" | jq -R . | jq -s 'map(tonumber)')" \
'.[] | select(.properties["application.process.id"] | tonumber | IN($pids[])) | .index' | head -n1)
if [ -z "$sink" ]; then
echo "[ERROR] No audio stream found for Deezer."
exit 1
fi
pactl set-sink-input-volume "$sink" "$action"
;;
esac
#
# # 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"
#

View File

@ -1,77 +0,0 @@
#!/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"