#!/bin/bash # pw-mute-active-window: 2024 Christian Birchinger # # Mute the active (X11) window applications incl. terminal programs with Pipewire. # Mostly usefull as a global hotkey. The initial idea was to do this for sink # switching, but wpcli or similar tools don't have this option for PIDs, so more # manual pw-dump and json magic would be required. # function getpids() { echo "${wpid}" cpids=$(pgrep -P "$1" | xargs) for cpid in ${cpids}; do echo "$cpid" ${FUNCNAME[0]} "${cpid}" done } wid=$(xdotool getwindowfocus) wprop=$(xprop -id "${wid}") wpid=$(grep '^_NET_WM_PID' <<< "${wprop}" | grep -oE '[[:digit:]]*$') mapfile -t pids <<< "$(getpids "${wpid}")" for p in "${pids[@]}"; do wpctl set-mute --pid "${p}" toggle done