Pre Requirements
- Install rsstail package
For Ubuntu: apt install rsstail
Fedora: dnf install rsstail
- Install curl package
For Ubuntu: apt install curl
For Fedora: dnf install curl
In this example I am using /opt/rssnewsfeed location
Make a folder inside the "rssnewsfeed" folder base on the feed name.
Ex: aljazeera
mkdir aljazeeraCreate a file aljazeera.sh file in side the "aljazeerha folder and past the below content.
#!/bin/bash
#eval "export $(pgrep -u $LOGNAME gnome-session | head -n 1 | xargs -I{} cat /proc/{}/environ | egrep -z DBUS_SESSION_BUS_ADDRESS)";
export "DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/1000/bus"
_dir="$( cd -P "$( dirname "$0" )" && pwd )"
cd $_dir
_feedname="aljazeera"
_url="https://www.aljazeera.com/xml/rss/all.xml"
_status=`/usr/bin/curl -s -o /dev/null -I -w "%{http_code}" "$_url"`
if [ $_status -ne "200" ];
then
exit 99
fi
/usr/bin/rsstail -1 -u "$_url" -lp -H -n 1 > ./$_feedname
_TITLE=`cut ./$_feedname -d$'\n' -f2`
_LINK=`cut ./$_feedname -d$'\n' -f3`
_TIME=`cut ./$_feedname -d$'\n' -f4 | cut -d' ' -f6`
if [ ! -f ./lastnewstime ];
then
touch lastnewstime
echo "00:00:00" > ./lastnewstime
fi
_LAST_NEWS=`cat ./lastnewstime`
if [ $_TIME != $_LAST_NEWS ];
then
notify-send -i $_dir/$_feedname.png "$_TITLE" "$_LINK"
echo $_TIME > ./lastnewstime
fi
exit 0
Configurations
In .sh file we have change few values.
- DBUS_SESSION_BUS_ADDRESS
To get the "DBUS_SESSION_BUS_ADDRESS" value, you have to run below command in terminal.
pgrep -u $LOGNAME gnome-session | head -n 1 | xargs -I{} cat /proc/{}/environ | egrep -z DBUS_SESSION_BUS_ADDRESS
Update the "DBUS_SESSION_BUS_ADDRESS" value in the script.
- Feed Name and Feed URL
Make the .sh file executable.
chmod 755 aljazeera.sh
Cronjob Schedule
Type crontab -e in your terminal.
This cronjob will run every one minute.



No comments:
Post a Comment