~mil/sxmo-utils

ref: 5b705dc91b5ef06268ed00cb22bbed40c754c2de sxmo-utils/scripts/core/sxmo_vol.sh -rwxr-xr-x 782 bytes
5b705dc9baroque reduce notification spam in volume/brightness a month ago
                                                                                
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
#!/usr/bin/env sh

# include common definitions
# shellcheck source=scripts/core/sxmo_common.sh
. "$(dirname "$0")/sxmo_common.sh"

notify() {
	VOL="$(
		amixer get "$(sxmo_audiocurrentdevice.sh)" |
		grep -oE '([0-9]+)%' |
		tr -d ' %' |
		awk '{ s += $1; c++ } END { print s/c }'  |
		xargs printf %.0f
	)"
	dunstify -i 0 -u normal -r 998 "♫ Volume" "$VOL"
	sxmo_statusbarupdate.sh
}

up() {
	amixer set "$(sxmo_audiocurrentdevice.sh)" 1+
	notify
}
down() {
	amixer set "$(sxmo_audiocurrentdevice.sh)" 1-
	notify
}
setvol() {
	amixer set "$(sxmo_audiocurrentdevice.sh)" "$1"
	notify
}
mute() {
	sxmo_audiocurrentdevice.sh > /tmp/muted-audio.dev
	amixer set "$(cat /tmp/muted-audio.dev)" mute
	notify
}
unmute() {
	amixer set "$(cat /tmp/muted-audio.dev)" unmute
	notify
}

"$@"