-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathnotify.sh
executable file
·50 lines (40 loc) · 1.24 KB
/
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
#!/bin/bash
source config.cfg
figlet -f script "Your Notifications"
curl -s -X GET \
"https://graph.facebook.com/v2.2/me/notifications?fields=created_time%2Ctitle%2Clink%2Capplication&limit=10&access_token=$access_token">njson.data
length=$(jq -r ".data | length" njson.data)
echo $length
if [ $length -eq 0 ]; then
echo "Sorry no notifications to display!"
exit 0
fi
for((i=0;i<$length;i++))
do
#jq -r ".data[$i]" njson.data
title="$(jq -r ".data[$i].title" njson.data)"
category="$(jq -r ".data[$i].application.name" njson.data)"
link="$(jq -r ".data[$i].link" njson.data)"
cr_time="$(jq -r ".data[$i].created_time" njson.data)"
#source="$(jq -r ".data[$i].source" njson.data)"
if [ "$title" != "null" ]
then
echo -e "Notification $(echo "$i+1"|bc) :\n"$(jq -r ".data[$i].title" njson.data)
#if the json data does not bear a file name then print the Videolink
fi
if [ "$category" != "null" ]
then
echo "Category :" $(jq -r ".data[$i].application.name" njson.data)
fi
if [ "$cr_time" != "null" ]
then
echo "Notification raised at :" $(jq -r ".data[$i].created_time" njson.data)
fi
if [ "$cr_time" != "null" ]
then
echo "Link pointed by the Notification : " $(jq -r ".data[$i].link" njson.data)"seconds"
fi
#clear
printf "\n\n"
done
#rm njson.data