forked from sayan01/scripts
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathvol
executable file
·30 lines (29 loc) · 780 Bytes
/
vol
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
#!/bin/bash
# one command to set, increase, decrease, mute, and
# display sink volume
## usage:
## vol -> displays the current volume
## vol up/down -> increase/decrease volume by 5%
## vol 52% -> set the volume to 52%
## vol +17% -> increase the volume by 17%
## vol -14% -> decrease the volume by 14%
## vol mute -> toggle volume mute (turns mute on/off)
cmd="volume"
if [ -n "$1" ]
then
case $1 in
up) val="+5%";;
down) val="-5%";;
mute) cmd="mute"; val="toggle";;
*) val=$1;;
esac
pactl -- set-sink-"$cmd" "@DEFAULT_SINK@" "$val"
fi
# display volume
ps=$(amixer get Master | tail -n1)
vol=$(echo "$ps" | grep -Po ".*\[\K\d*%")
mute=$(echo "$ps" | grep -Po ".*\[\K\w*")
case $mute in
on) echo " $vol";;
*) echo "🔇";;
esac