My work computer is pretty restricted. I don't get any admin privileges at all. This is occasionally a real problem, like when I need something for development. But usually it's only a pain; although my browser's Java plugin only supports 1.4, I can't imagine a business case when I need a better one; after all, we're developing a real application, not an applet.

One such pain is the text in XScreenSaver. It's using uptime to provide text for the Star Wars screensaver and similar text-based modules, which is just boring. I'm allowed to specify a command that will produce text output, like fortune, but I'd like to get an RSS feed. And since xscreensaver-text isn't installed, all I can use is elinks, which puts raw HTML in the output.

So, being the Alpha Geek, I learned enough Python to read a feed. It's installed by default, but the Universal Feed Parser isn't. I had to figure out how to manipulate the module search path, read the arguments, and traverse and combine lists and dictionaries. No biggie. The source to my python "screenfeed" script is available if you read more.

Here's the script:

    
#!/usr/bin/python
import sys
#import random
sys.path.append('/path/to/feedparser')
import feedparser
if len(sys.argv) < 2:
  feeds = ['http://feeds.theonion.com/theonion/daily']
else:
  feeds = sys.argv[1:]
parsedfeeds = {}
for feed in feeds:
  d = feedparser.parse(feed)
  parsedfeeds[feed] = d;
#random.shuffle(allitems)
for key in parsedfeeds.keys():
  for i in parsedfeeds[key].entries:
    print '[%s]%s' % (parsedfeeds[key]['feed']['title'], i.title)
    print

  

I just made that executable, put it in my path, and now I've got the headlines displayed in a Star Wars marquee! I can even specify multiple feeds to read. Of course, it could be more sophisticated, but I think it's not bad for a first Python script.