summaryrefslogtreecommitdiffstats
path: root/.local/bin/statusbar/volume
blob: c3bf6d11f4cb7f9de0080cc1170c3b8a1aab5d61 (plain) (blame)
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
#!/usr/bin/env sh

case $BLOCK_BUTTON in
	1) setsid "$TERMINAL" -e alsamixer & ;;
	2) amixer sset Master toggle ;;
	4) amixer sset Master 5%+ >/dev/null 2>/dev/null ;;
	5) amixer sset Master 5%- >/dev/null 2>/dev/null ;;
	3) pgrep -x dunst >/dev/null && notify-send "📢 Volume module" "\- Shows volume 🔊, 🔇 if muted.
- Middle click to mute.
- Scroll to change."
esac

volstat="$(amixer get Master)"

echo "$volstat" | grep "\[off\]" >/dev/null && printf "🔇\\n" && exit

vol=$(echo "$volstat" | grep -o "\[[0-9]\+%\]" | sed 's/[^0-9]*//g')

if [ "$vol" -gt "70" ]; then
	icon="🔊"
elif [ "$vol" -lt "30" ]; then
	icon="🔈"
else
	icon="🔉"
fi

printf "%s %s%%\\n" "$icon" "$vol"