You are not logged in.
Pages: 1
#!/bin/bash
#Check for new XKCD comics.
#So far only able to see if a new one
#is present, not able to discern how
#many new ones exist.
#Each comic is uniquely names and we
#can just compare the line including
#the comic name in the html file
#against the line including the comic
#name the script stored on the last run.
#Get the latest one into .latestxkcd
#On first run create .lastseenxkcd
#We will know if there's a new one if the
#two files aren't the same
wget --quiet -O .xkcdtmp http://xkcd.com
touch .lastseenxkcd
#This strips the HTML file down to be
#exclusively the line with the comic name.
cat .xkcdtmp | grep "img src" | sed -e '3,50d' | sed -e '1d' >> .latestxkcd
rm .xkcdtmp
if [ "$(cat .latestxkcd)" != "$(cat .lastseenxkcd)" ]
then echo "New XKCD comic!"
else
echo "No new XKCD comic"
fi
#Update the last seen comic
rm .lastseenxkcd
mv .latestxkcd .lastseenxkcd
#EOF
Thought this seems like one of the conky scripts that was missing.
The human being created civilization not because of willingness but of a need to be assimilated into higher orders of structure and meaning.
Offline
Alternatively, you could just parse the RSS feed and also get the titles of the new comics. I think that there already exist RSS-parse scripts for conky.
- blog (about arch and other stuff): http://thoughtyblog.wordpress.com/
- x86_64 user
Offline
I wonder if curl -I works in this case.
{ date '+%s'; date +'%s' -d "$(curl -s -I 'http://xkcd.com' | grep -F 'Last-Modified' | cut -d' ' -f2-)"; echo [last comic: ]n-60/d60/n[h ]n60%n[m ago]p; } | dc
edit: moved a `d`
Last edited by Procyon (2010-01-25 22:01:18)
Offline
Pages: 1