-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathnotifyer
executable file
·58 lines (47 loc) · 1.05 KB
/
notifyer
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
#!/bin/sh
# make sure the widget is
# "custom/athan": {
# "format": " {}",
# "exec": "<Path to this file> <latitude> <Longitude>",
# "interval": 60,
# }
STATUS_PATH="$XDG_RUNTIME_DIR/waybar_athan.status"
prayer=$(~/.cargo/bin/waybar_athan -l "$1" -L "$2" -v)
class=$(echo "$prayer" | tail -n 1)
text=$(echo "$prayer"| head -n 1)
name=$(echo "$text" | cut -f1 -d" ")
case "$class" in
remaining)
status=0
;;
before)
status=1
;;
athan)
status=2
;;
past)
status=3
;;
esac
if ! [ -f "$STATUS_PATH" ]; then
echo "$name:$status" > "$STATUS_PATH"
fi
old_name=$(cat "$STATUS_PATH" | cut -f1 -d":")
if ! [ "$old_name" = "$name" ]; then
old_status=0
else
old_status=$(cat "$STATUS_PATH" | cut -f2 -d":")
fi
if [ "$status" -gt "$old_status" ]; then
case "$status" in
1)
notify-send -u normal -a "Athan Notify" -i "compass" "Athan" "$text"
;;
2)
notify-send -u critical -a "Athan Notify" -i "compass" "Athan" "$text"
;;
esac
fi
echo "$name:$status" > "$STATUS_PATH"
echo "$prayer"