Fetch, Parse, and Crop RSS for conky need.
#!/bin/bash
# deps:
# curl
# Usage:
# .conkyrc: ${execi [time] /path/to/script/conky-rss.sh URI LINES TITLENUM}
# URI = Location of feed, ex. http://www.gentoo.org/rdf/en/glsa-index.rdf
# LINES = How many titles to display (default 5)
# TITLENUM = How many times the title of the feed itself is specified, usually 1 or 2 (default 2)
#
# Usage Example
# ${color #98c2c7}BBC News Front Page:
# ${color #c4c4c4}${execi 300 ~/conky-rss.sh http://newsrss.bbc.co.uk/rss/newsonline_world_edition/front_page/rss.xml 5 2}
#RSS Setup
uri=$1 #URI of RSS Feed
lines=$2 #Number of headlines
titlenum=$3 #Number of extra titles
#Script start
if [[ "$uri" == "" ]]; then
echo "No URI specified!" >&2
else
#Set defaults if none specified
if [[ $lines == "" ]]; then lines=5 ; fi
if [[ $titlenum == "" ]]; then titlenum=2 ; fi
#The actual work
curl -s --connect-timeout 30 $uri |\
sed -e 's/<\/title>/\n/g' |\
grep -o '<title>.*' |\
sed -e 's/<title>//' |\
head -n $(($lines + $titlenum)) |\
tail -n $(($lines))
fi
Rekomendasi Game Android Bahasa Indonesia
3 years ago
0 comments:
Post a Comment