diff --git a/scripts/spot_volume.sh b/scripts/spot_volume.sh new file mode 100755 index 0000000..85c174f --- /dev/null +++ b/scripts/spot_volume.sh @@ -0,0 +1,35 @@ +#!/usr/bin/env bash + + +id=$(pw-dump | jq ' + map( + select( + .info.props."application.name" == "spotify" and + .type == "PipeWire:Interface:Node") + )[-1].id' +) +current_volume=$(pw-dump | jq " + .[] | + select(.id == $id) | + .info.params.Props[0].volume" +) + +new_volume=current_volume + +case $1 in + *+) + if [ "$(bc <<< "$current_volume < 1")" -eq 1 ]; then + new_volume=$(bc <<< "$current_volume + ${1%+}") + fi + ;; + *-) + if [ "$(bc <<< "$current_volume > 0")" -eq 1 ]; then + new_volume=$(bc <<< "$current_volume - ${1%-}") + fi + ;; + *) + new_volume=$1 + ;; +esac + +pw-cli set-param "$id" Props "{volume: $new_volume}"