-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathchangevolume
More file actions
executable file
·36 lines (32 loc) · 1001 Bytes
/
changevolume
File metadata and controls
executable file
·36 lines (32 loc) · 1001 Bytes
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
# Taken and modified from: https://github.com/ericmurphyxyz/dotfiles/blob/master/.local/bin/changevolume
# Increment, decrement, or mute the volume and send a notification of the current volume level.
send_notification() {
volume=$(wpctl get-volume @DEFAULT_AUDIO_SINK@ | tr -dc "0-9" | sed 's/^0\{1,2\}//')
notify-send -a "changevolume" \
-u low \
-r 9993 \
-h int:value:"$volume" \
-i "${XDG_CONFIG_HOME}/dunst/icons/volume-$1.png" \
"Volume: ${volume}%" \
-t 3000
}
case $1 in
up)
# Set the volume on (if it was muted)
wpctl set-volume @DEFAULT_AUDIO_SINK@ 3%+
send_notification "$1"
;;
down)
wpctl set-volume @DEFAULT_AUDIO_SINK@ 3%-
send_notification "$1"
;;
mute)
wpctl set-mute @DEFAULT_AUDIO_SINK@ toggle
if [ "$(wpctl get-volume @DEFAULT_AUDIO_SINK@ | grep -oE "[A-U]+")" = "MUTED" ]; then
notify-send -a "changevolume" -t 2000 -r 9993 -u low -i "${XDG_CONFIG_HOME}/dunst/icons/volume-mute.png" "Volume Muted"
else
send_notification up
fi
;;
esac