-
Notifications
You must be signed in to change notification settings - Fork 348
/
Copy pathprogress-notify.sh
executable file
·75 lines (64 loc) · 2.83 KB
/
progress-notify.sh
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
68
69
70
71
72
73
74
75
#!/usr/bin/env sh
# progress-notify - Send audio and brightness notifications for dunst
# dependencies: dunstify, ponymix, Papirus (icons)
### How to use: ###
# Pass the values via stdin and provide the notification type
# as an argument. Options are audio, brightness and muted
### Audio notifications ###
# ponymix increase 5 | notify audio
# ponymix decrease 5 | notify audio
# pulsemixer --toggle-mute --get-mute | notify muted
### Brightness notifications ###
# xbacklight -inc 5 && xbacklight -get | notify brightness
# xbacklight -dec 5 && xbacklight -get | notify brightness
notifyMuted() {
volume="$1"
dunstify -h string:x-canonical-private-synchronous:audio "Muted" -h int:value:"$volume" -t 1500 --icon audio-volume-muted
}
notifyAudio() {
volume="$1"
ponymix is-muted && notifyMuted "$volume" && return
if [ $volume -eq 0 ]; then
notifyMuted "$volume"
elif [ $volume -le 30 ]; then
dunstify -h string:x-canonical-private-synchronous:audio "Volume: " -h int:value:"$volume" -t 1500 --icon audio-volume-low
elif [ $volume -le 70 ]; then
dunstify -h string:x-canonical-private-synchronous:audio "Volume: " -h int:value:"$volume" -t 1500 --icon audio-volume-medium
else
dunstify -h string:x-canonical-private-synchronous:audio "Volume: " -h int:value:"$volume" -t 1500 --icon audio-volume-high
fi
}
notifyBrightness() {
brightness="$1"
if [ $brightness -eq 0 ]; then
dunstify -h string:x-canonical-private-synchronous:brightness "Brightness: " -h int:value:"$brightness" -t 1500 --icon display-brightness-off-symbolic
elif [ $brightness -le 30 ]; then
dunstify -h string:x-canonical-private-synchronous:brightness "Brightness: " -h int:value:"$brightness" -t 1500 --icon display-brightness-low-symbolic
elif [ $brightness -le 70 ]; then
dunstify -h string:x-canonical-private-synchronous:brightness "Brightness: " -h int:value:"$brightness" -t 1500 --icon display-brightness-medium-symbolic
else
dunstify -h string:x-canonical-private-synchronous:brightness "Brightness: " -h int:value:"$brightness" -t 1500 --icon display-brightness-high-symbolic
fi
}
input=`cat /dev/stdin`
case "$1" in
muted)
volume=`ponymix get-volume`
if [ "$input" -eq 0 ]
then
notifyAudio "$volume"
else
notifyMuted "$volume"
fi
;;
audio)
notifyAudio "$input"
;;
brightness)
notifyBrightness "$input"
;;
*)
echo "Not the right arguments"
echo "$1"
exit 2
esac