diff --git a/home/sound-levels-maintainer/scripts/sound-levels-maintainer-boar.sh b/home/sound-levels-maintainer/scripts/sound-levels-maintainer-boar.sh index c88be9d..a81534b 100644 --- a/home/sound-levels-maintainer/scripts/sound-levels-maintainer-boar.sh +++ b/home/sound-levels-maintainer/scripts/sound-levels-maintainer-boar.sh @@ -1,17 +1,25 @@ set -euo pipefail -VIRTUAL_SPEAKER_ID=86 -OBS_MIC_ID=92 +get_pipewire_node_id() { + local node_name="$1" + pw-cli ls Node | awk -v name="$node_name" ' + $1 == "id" { id=$2 } + /node.name/ && $3 == "\"" name "\"" { gsub(/,/, "", id); print id } + ' +} -wpctl set-volume $VIRTUAL_SPEAKER_ID 1.0 -wpctl set-volume $OBS_MIC_ID 1.0 +OBS_SPEAKER_ID=$(get_pipewire_node_id "ObsSpeaker") +OBS_MIC_ID=$(get_pipewire_node_id "ObsMic") + +wpctl set-volume "$OBS_SPEAKER_ID" 1.0 +wpctl set-volume "$OBS_MIC_ID" 1.0 while true; do - current_volume_virtual_speaker=$(wpctl get-volume $VIRTUAL_SPEAKER_ID | awk '{print $2}') - current_volume_obs_mic=$(wpctl get-volume $OBS_MIC_ID | awk '{print $2}') + current_volume_obs_speaker=$(wpctl get-volume "$OBS_SPEAKER_ID" | awk '{print $2}') + current_volume_obs_mic=$(wpctl get-volume "$OBS_MIC_ID" | awk '{print $2}') - [ "$current_volume_virtual_speaker" != "1.0" ] && wpctl set-volume $VIRTUAL_SPEAKER_ID 1.0 - [ "$current_volume_obs_mic" != "1.0" ] && wpctl set-volume $OBS_MIC_ID 1.0 + [ "$current_volume_obs_speaker" != "1.0" ] && wpctl set-volume "$OBS_SPEAKER_ID" 1.0 + [ "$current_volume_obs_mic" != "1.0" ] && wpctl set-volume "$OBS_MIC_ID" 1.0 sleep 1 done