OSDN Git Service

6a404c7f9778edc2ad1b8280942dea339bb043b0
[instantos/instantOS.git] / programs / dunsttrigger
1 #!/bin/dash
2
3 # gets executed each time dunst receives a notification
4
5 # ignore some apps
6 if echo "$2" | grep -q 'instantASSIST'; then
7     exit
8 fi
9
10 if ! echo "$1" | grep -Eiq '(discord|spotify|thunderbird|mailspring)'; then
11     if ! [ -e ~/instantos/notifications/notification.ogg ]; then
12         if ping -c 1 google.com; then
13             mkdir -p ~/instantos/notifications/
14             wget -qO ~/instantos/notifications/notification.ogg \
15                 "https://notificationsounds.com/notification-sounds/me-too-603/download/ogg"
16         else
17             exit
18         fi
19     fi
20     mpv ~/instantos/notifications/notification.ogg
21 fi
22
23 # escape characters that cause problems with pango
24 # some apps dont need/already have notification sounds
25 cleanstring() {
26     echo "$@" | sed 's/&/&/g'
27 }
28
29 # add pango markup
30 echo "($(date +%H:%M)) [$(cleanstring $1)] <b>$(cleanstring $2)</b> | <i>$(cleanstring $3)</i>" >>/tmp/notifications/notif.txt