Files
bash-scripts/old/spotify-volume.sh.o
2026-06-06 12:24:00 +02:00

75 lines
1.2 KiB
Bash
Executable File

#!/bin/bash
# check command line arguments first
if [ $# != 1 ]; then
echo "Usage ${0} up|down|mute"
exit 1
fi
if [ $1 != "up" -a $1 != "down" -a $1 != "mute" ]; then
echo "Usage ${0} up|down|mute"
exit 1
fi
# go through each line of the sink-inputs output
pactl list sink-inputs | while read line; do
# Update current sink input id
[[ $line =~ ^Sink\ Input\ \#([[:digit:]]+) ]] && this_input=${BASH_REMATCH[1]}
# check if it is spotify
if [[ $line =~ "application.name = \"spotify\"" ]]; then
echo "Spotify is sink-input ${this_input}"
case $1 in
up)
pactl set-sink-input-volume ${this_input} +5%
;;
down)
pactl set-sink-input-volume ${this_input} -5%
;;
mute)
pactl set-sink-input-mute ${this_input} toggle
;;
*)
echo "Error"
;;
esac
fi
done