forked from ThatsRedacted/StationNotifier
-
Notifications
You must be signed in to change notification settings - Fork 0
/
notificatorossl
executable file
·61 lines (55 loc) · 1.63 KB
/
notificatorossl
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
#!/usr/bin/env bash
# notifitcatorossl is a fork of https://github.com/ThatsRedacted/StationNotifier
# This program uses openssl rather than curl to connect to a gemini site`
key='/home/frrobert/.config/amfora/7debbb3fae40dbe77746aa465300febaec5abb778faa8a550f8e5924f0977983.key'
cert='/home/frrobert/.config/amfora/7debbb3fae40dbe77746aa465300febaec5abb778faa8a550f8e5924f0977983.crt'
connectto=30
howoften=
tmpfile=$(mktemp /tmp/not.XXXXXX)
url="gemini://station.martinrue.com/frrobert"
lasttime=0
trap ctrl_c INT
function ctrl_c() {
rm -f $tmpfile
exit 0
}
while [ true ]
do
if [[ "$url" != *://* ]];then
domain="$url"
url="gemini://$url"
else
domain=$(sed 's/gemini:\/\///' <<< "$url")
fi
if [[ "$url" != *.*/*.* ]] && [[ $url != */ ]];then
url="$url/"
fi
domain=$(sed 's/\/.*$//' <<< "$domain")
timeout $connectto openssl s_client -crlf -quiet -key $key -cert $cert -connect "$domain:1965" <<<"$url" 2>/dev/null >> $tmpfile
IFS=' ' read -ra my_array <<< $(cat $tmpfile | grep '/notifications')
notifications=${my_array[2]}
echo "" > $tmpfile
if [[ $notifications -gt $lasttime ]]; then
new=$(expr $notifications - $lasttime)
echo -en "\007"
echo "You have $notifications notifications and $new new notifications!"
read -p "Press enter to continue, or either type amfora or lagrange to go to notifications" answer
case $answer in
amfora)
amfora $url
clear
;;
lagrange)
lagrange $url
clear
;;
*)
clear
;;
esac
echo "waiting for new notifications"
lasttime=$notifications
unset my_array
fi
sleep 600
done