blob: 7d0edb9f551acf0cf8363d4345345f8dab8eb3ca (
plain)
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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
|
#!/bin/sh
help() { echo "volctl - change system volume
USAGE: volctl <toggle|up|down>"; }
[ "$#" -lt 1 ] && help >&2 && exit 1
case "$1" in
toggle) wpctl set-mute @DEFAULT_SINK@ toggle ;;
up) wpctl set-volume @DEFAULT_SINK@ 5%+ ;;
down) wpctl set-volume @DEFAULT_SINK@ 5%- ;;
*) help >&2; exit 1 ;;
esac
vol="$(wpctl get-volume @DEFAULT_SINK@ | tr -d .)"
vol="${vol#Volume: }"
notify() {
if [ -n "$DISPLAY" ]; then
notify-send -t 3000 -r 93475 "$1"
else
printf 'volume : '
wpctl get-volume @DEFAULT_SINK@
fi
}
if [ "$vol" != "${vol% \[MUTED\]}" ]; then
vol="${vol% \[MUTED\]}"
muted=1
else
muted=0
fi
vol="$(printf '%.0f' "$vol")"
msg=""
if [ "$vol" -gt "100" ]; then icon="📢"; msg=" Boosted"
elif [ "$vol" = "100" ]; then icon="🔊"; msg=" Maxed"
elif [ "$vol" -gt "70" ]; then icon="🔊"
elif [ "$vol" -gt "30" ]; then icon="🔉"
elif [ "$vol" -gt "0" ]; then icon="🔈"
else icon="🔇"
fi
if [ "$muted" -eq 1 ]; then
notify "🔇 Volume Muted ($vol%)"
else
notify "$icon Volume$msg: $vol%"
fi
|