Created
October 30, 2018 21:58
-
-
Save ZsemberiDaniel/aa25e427e4b046db2c57350d42e7a351 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
increase=0 | |
if [ $# -lt 1 ] || [ $1 -gt 0 ];then | |
increase=1 | |
else | |
increase=-1 | |
fi | |
spotify_at=-1 | |
i=1 | |
for name in `pactl list sink-inputs | grep 'application.name' | cut -d= -f2`;do | |
if [[ $name =~ "spotify" ]];then | |
spotify_at=$i | |
fi | |
i=`expr $i + 1` | |
done | |
spotify_id=`pactl list sink-inputs | grep 'Sink Input' | cut -d# -f2` | |
if [ ! $spotify_at -eq -1 ];then | |
curr_volume=`pactl list sink-inputs | grep 'Volume' | cut -d'/' -f2 | sed "${spotify_at}!d" | sed 's/%//g'` | |
new_volume=`expr $curr_volume + \`expr $increase \\\* 10\`` | |
if [ $new_volume -gt 100 ];then | |
new_volume=100 | |
elif [ $new_volume -lt 0 ];then | |
new_volume=0 | |
fi | |
pactl set-sink-input-volume $spotify_id "${new_volume}%" | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment