-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathvolume.sh
More file actions
executable file
·56 lines (50 loc) · 1.49 KB
/
volume.sh
File metadata and controls
executable file
·56 lines (50 loc) · 1.49 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
#!/bin/sh
# You can call this script like this:
# $ ./volumeControl.sh up
# $ ./volumeControl.sh down
# $ ./volumeControl.sh mute
# Script modified from these wonderful people:
# https://github.com/dastorm/volume-notification-dunst/blob/master/volume.sh
# https://gist.github.com/sebastiencs/5d7227f388d93374cebdf72e783fbd6a
# aaand modified by meee
get_volume() {
amixer -c 1 get Master | grep '%' | head -n 1 | cut -d '[' -f 2 | cut -d '%' -f 1
}
is_mute() {
amixer -c 1 get Master | grep '%' | grep -oE '[^ ]+$' | grep off > /dev/null
}
send_notification() {
iconSound="墳"
iconMuted="婢"
if is_mute ; then
dunstify -r 2593 -u normal " $iconMuted "
else
volume=$(get_volume)
# Make the bar with the special character ─ (it's not dash -)
# https://en.wikipedia.org/wiki/Box-drawing_character
slashes=$(( volume / 5 ))
blanks=$(( $(( 100 - volume )) / 5 ))
bar=$(seq -s "█" 0 $slashes | sed 's/[0-9]//g')$(seq -s " " 0 $blanks | sed 's/[0-9]//g')"▏"
# Send the notification
dunstify -r 2593 -u normal " $iconSound $bar"
fi
}
case $1 in
up)
# set the volume on (if it was muted)
amixer -c 1 set Master on > /dev/null
# up the volume (+ 5%)
amixer -c 1 sset Master 5%+ > /dev/null
send_notification
;;
down)
amixer -c 1 set Master on > /dev/null
amixer -c 1 sset Master 5%- > /dev/null
send_notification
;;
mute)
# toggle mute
amixer -c 1 set Master 1+ toggle > /dev/null
send_notification
;;
esac