-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathvolume
More file actions
executable file
·67 lines (55 loc) · 1.61 KB
/
Copy pathvolume
File metadata and controls
executable file
·67 lines (55 loc) · 1.61 KB
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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
#!/usr/bin/env bash
## Script To Manage Speaker Volume For Archcraft (in Wayland).
icons="$HOME/.config/hypr/icons"
# Get Volume
get_volume() {
volume=`amixer -D pulse get Master | awk NR==7 | awk '{print $5}' | tr -d "[]%"`
echo "$volume"
}
# Get icons
get_icon() {
volume="$(get_volume)"
current="${volume}"
if [[ "$current" -eq "0" ]]; then
icon="$icons/volume-mute.png"
elif [[ ("$current" -ge "0") && ("$current" -le "30") ]]; then
icon="$icons/volume-low.png"
elif [[ ("$current" -ge "30") && ("$current" -le "60") ]]; then
icon="$icons/volume-mid.png"
elif [[ ("$current" -ge "60") && ("$current" -le "100") ]]; then
icon="$icons/volume-high.png"
fi
}
# Notify
notify_user() {
notify-send -h string:x-canonical-private-synchronous:sys-notify -u low -i "$icon" "Volume: $(get_volume)"
}
# Increase Volume
inc_volume() {
amixer -D pulse sset Master 5%+ unmute && get_icon && notify_user
}
# Decrease Volume
dec_volume() {
amixer -D pulse sset Master 5%- unmute && get_icon && notify_user
}
# Toggle Mute
toggle_mute() {
status=`amixer get PCM | tail -n1 | grep -wo 'on'`
if [[ "$status" == "on" ]]; then
amixer set PCM toggle && notify-send -h string:x-canonical-private-synchronous:sys-notify -u low -i "$icons/volume-mute.png" "Mute"
else
amixer set PCM toggle && get_icon && notify-send -h string:x-canonical-private-synchronous:sys-notify -u low -i "$icon" "Unmute"
fi
}
# Execute accordingly
if [[ "$1" == "--get" ]]; then
get_volume
elif [[ "$1" == "--inc" ]]; then
inc_volume
elif [[ "$1" == "--dec" ]]; then
dec_volume
elif [[ "$1" == "--toggle" ]]; then
toggle_mute
else
get_volume
fi