I am trying to write a script that allows me to change Bluetooth speaker volume from the shell. I can hard code the value of the sink and it works just fine:
#!/usr/bin/env bash for level in "$@" do pactl set-sink-input-volume 267 $level done
I get the "267" value by running:
pactl list sink-inputs
Which provides output like:
Sink Input #267 Driver: protocol-native.c Owner Module: 10 Client: 151 Sink: 7 Sample Specification: float32le 2ch 44100Hz Channel Map: front-left,front-right ⋮
All I care about is that three digit value in the first line of out put after Sink Input #
Like I said, if I hardcode that 267 value in the script, everything works fine until I restart the Bluetooth speaker, then the value changes.
Is there a way I can extract that value via the script and pass it as a variable to the
pactl set-sink-input-volume 267 $level bit of the script?