aboutsummaryrefslogtreecommitdiff
path: root/i3blocks/i3vol.sh
blob: 55aabee663e21c5cce0e49f42548ca08481736cd (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
#!/bin/sh

LANG='en_US.UTF-8'

case $BLOCK_BUTTON in
	1) i3-msg 'exec urxvt -e alsamixer' >/dev/null ;;
	3) pgrep -x dunst >/dev/null &&
		notify-send -h string:x-canonical-private-synchronous:i3volHint -t 2000 'Click for alsamixer' ;;
esac

sink="$(pactl list sinks short |
	grep 'RUNNING' |
	cut -f2)"

vol="$(pactl list sinks |
	grep -e 'Name' -e 'Volume: f' |
	grep -A 1 "$sink" |
	tail -n 1 |
	awk '{print $5}' |
	sed 's/%.*$/%/')"

mute="$(pactl list sinks |
	grep -e 'Name' -e 'Mute:' |
	grep -A 1 "$sink" |
	tail -n 1 |
	cut -d' ' -f2)"

if [ "$mute" = 'no' ]; then
	echo "🔊 $vol"
else
	echo "🔇($vol)"
fi