~jbauer/dotfiles

ref: daebf07b03e1fe9fe376eb75d5dd061c8fa047d3 dotfiles/.local/bin/change-volume -rwxr-xr-x 845 bytes
daebf07bJake Bauer Update README 11 months 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
#!/bin/sh
# Thank you Arch Wiki: https://wiki.archlinux.org/index.php/Dunst#Dunstify

# Arbitrary but unique message id
msgId="509842"

# Set the volume based on args given
if [ "$1" = "up" ]; then
	sndioctl output.level=+0.05
elif [ "$1" = "down" ]; then
	sndioctl output.level=-0.05
elif [ "$(sndioctl output.mute | cut -d= -f2)" -eq 0 ]; then
	sndioctl output.mute=1
	muted=1
else
	sndioctl output.mute=0
fi

volume=$(sndioctl output.level | cut -d= -f2)

if [ "$volume" = "1.000" ]; then
	volume=100
else
	volume=$(echo "$volume" | cut -d. -f2)
	volume=$(($volume/10))
	echo "$volume"
fi

if [ "$muted" -eq 1 ]; then
    # Show the sound muted notification
    dunstify -a "changeVolume" -u low -r "$msgId" "Volume muted"
else
    # Show the volume notification
    dunstify -a "changeVolume" -u low -r "$msgId" "Volume: $volume%"
fi
exit 0