Skip to content

Commit

Permalink
feat(sound-levels-maintainer): fetch PipeWire Node IDs dynamically based
Browse files Browse the repository at this point in the history
on name
  • Loading branch information
workflow committed Nov 20, 2024
1 parent 60bf85f commit eba7557
Showing 1 changed file with 16 additions and 8 deletions.
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit eba7557

Please sign in to comment.