forked from km4ack/Pi-APRS
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmsg-alert
executable file
·63 lines (49 loc) · 1.4 KB
/
msg-alert
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
#!/bin/bash
source $HOME/Pi-APRS/config
#message alert for pi-aprs
#20200417 km4ack
CALL="$MYCALL-$SSID"
MSGFLAG=/run/user/1000/.msg
FILE=/run/user/1000/pi-aprs.log
FILE1=/run/user/1000/pi-aprs1.log
touch $FILE $FILE1
counter=1
rm $MSGFLAG > /dev/null 2>&1
while true
do
CHECK=$(diff $FILE $FILE1)
sleep .5
#look for differences in two files
if [ -z "$CHECK" ]; then
clear
echo "Listening for incoming messages"
echo "CTRL+C to EXIT"
else
#Look for changes in file
MSG=$(cat $FILE | tail -3 | grep -i $CALL | head -1 | sed 's/^.*://' | sed 's/{.*$//')
#FROM=$(cat $FILE | tail -3 | grep -i $CALL | head -1 | awk '{print $2}' | sed 's/>.*$//')
FROM=$(cat $FILE | tail -3 | grep -i $CALL | head -1 | awk '{print $2}' | sed 's/^.*}//' | sed 's/>.*$//')
#verify message is address to our station
if [ -z "$FROM" ]; then
clear
echo "####################"
echo "found but not for me"
echo "####################"
cp $FILE $FILE1
#notify with popup if message is found
else
if [ ! -f "$MSGFLAG" ]; then
yad --center --width=800 --wrap --window-icon=$HOME/Pi-APRS/ISS.png --title="New Message" --form --separator="|" --item-separator="," --field="From":RO "$FROM" --field="Message":RO "$MSG" --button=gtk-ok:1 &
aplay --device plughw:0,0 -t wav $NEWMSG
cp $FILE $FILE1
else
clear
echo "Message was outgoing. Don't Alert"
cp $FILE $FILE1
rm $MSGFLAG
fi
fi
fi
((counter++))
echo $counter
done