The power of Ubuntu – showing dynamic messages in your desktop background!

I worked on this cool hack to dynamically show Twitter messages embedded into the desktop background. The basic idea is to have some dynamic text (which could be fetched from the web) embedded in an SVG image, which is set as the desktop background. The SVG image contains the actual wallpaper that we intend to use.

[ad name=”blog-post-ad-wide”]

Here are the steps:

  1. We first start by creating an SVG template file called wall-tmpl.svg with the following contents and saving it in the Wallpapers directory (let’s say it is ~/Theme/Wallpapers):
    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.0//EN" "" [
    <!ENTITY ns_imrep "">
    <!ENTITY ns_svg "">
    <!ENTITY ns_xlink "">
    <svg xmlns="" xmlns:xlink="" width="1280" height="1024" viewBox="0 0 1280 1024" overflow="visible" enable-backgroun
    d="new 0 0 132.72 127.219" xml:space="preserve">
    <image xlink:href="~/Theme/Wallpapers/-your-favorite-wall-paper-" x="0" y="0" width="1280" height="1024"/>
    <text x="100" y="200" fill="white" font-family="Nimbus Mono L" font-size="14" kerning="2">%text</text>
  2. Next we create a script to fetch the most recent Twitter message and then embedding it in the image. The script is called change-wallpaper and is placed in the bin directory. It has the following:
    text=`python -c "import urllib;print eval(urllib.urlopen('').read().replace('false', 'False').replace('true', 'True
    ').replace('null', 'None'))['results'][0]['text'].replace('\!','').replace('/','\/')"`
    cat ~/Theme/Wallpapers/wall-tmpl.svg | sed "s/%text/$text/g" > ~/Theme/Wallpapers/wall.svg
  3. We then add the following entry to crontab to fetch Twitter messages every minute:
    # m h dom mon dow command
    * * * * * ~/bin/change-wallpaper
  4. Run the script once, it will create a file called wall.svg in your Wallpapers directory. Set this as your desktop background and watch the background change every minute!

You could get very creative with this. You could have your calendar reminders embedded directly into your desktop background or you could have dynamically fetched background images with your own random fortune quote. The possibilities are enormous!

World Wide Web

My weekend hack – Twitter Trending Topics

I got this idea of building an application which pulls all the pages mentioned in the trending topics on Twitter. Why would that be useful? Well, it’s the simplest replacement for Google News, but more real time and no tweet noise.

Here are the steps I followed to build this application:

  1. The first step was to use IPython and use the Twitter Search API to get the latest tweets.
  2. I then wrote the code to parse these tweets looking for URL’s in them.
  3. The next step was to get the content from these URL’s, and get the title of the pages.
  4. Next, I had to persist it in the store.
  5. Slap a front-end and allow navigation. At this point, the obvious choice for me was Google AppEngine, since it is the cheapest hosting alternative available. I had to make some changes to the application to accommodate it to Google AppEngine’s requirements, but they were mostly trivial.
  6. Build the styles, the icons, the pretty URL’s and you are done!

The initial setup of the application was done in less than 2 hours time!

You can access the application here: Twitter Trending Topics.

There are a few known bugs, but the overall results are impressive.

My Updates

Hackday @ IBM

The power of blogging was apparent. IBM had its first unofficial HackDay.

What was impressive was that the contest and the details spread through blogging and then got publicity because it was recognized by some of the biggies.

I participated. I came up with a simple and useful hack, which has been listed under the 'Best improvement' category. More details about the event can be found here.

There were calls, where participants discussed their hacks.

Thanks to all the organizers.

Awaiting the next one! 🙂

technorati tags:, , , ,