Dynamic Wallpaper
Matty — Tue, 2010-07-20 17:45
Skip to the end if you just want to try it out, the process description is pretty long... Here's what one of the 8 phases looks like: http://img844.imageshack.us/img844/2016/57179053.jpg
Since I am switching over to a new machine I've been creating a custom Ubuntu install to take with me. While looking around the net i stumbled upon the idea of a dynamic wallpaper. Unfortunately I've heard these are far too CPU intensive for the task they perform due to constantly checking their conditions for updating. So I decided to have a go at creating my own.
Most dynamic wallpapers operate on a day/night or seasons basis, this is complicated when creating one as a series of images for the same scene at different times would be needed. Instead of using day and night for the change of wallpaper, I decided to use the phases of the moon. I found a script online that calculates the moon phase (It is possible to pull the information from online, however I would like the script to work offline). The original script can be found here: http://jivebay.com/2008/09/07/calculating-the-moon-phase/
For the most part this worked as-is, however bash had a problem with the string outputs (New Moon, Waxing Crescent Moon etc), so I replaced them with a number (0-7). I now had a working script to tell me the phase of the moon, so I went searching for images for it to set to the background. I eventually settled on a city view, found here: http://commons.wikimedia.org/wiki/File:New_York_City_at_night_HDR.jpg. The image is licensed under the creative commons attribution-share, so you're allowed to modify and distribute it as long as you credit the author.
I found the original image was a little bland, so I fired up gimp to do some editing. I used colourise (Colours->Colourise) to add a bluish grey color, giving me this: http://img210.imageshack.us/img210/9679/ny2p.jpg. I then combined (Filters->Combine->Depth Merge) this with the original image, changing the source and depth map selections to the original and edited layers. This gave me the base image for the background: http://img837.imageshack.us/img837/8616/ny3.jpg
Next I found images showing each phase of the moon: http://commons.wikimedia.org/wiki/File:Joka2000_-_Moon_in_Dec_2005_%28by.... Since just cutting and pasting these phases onto the image would leave ugly blackspace I needed to do some editing before moving the images. I used Layer->Transparancy->Colour to Alpha to change black to an alpha channel. If you do the same you'll notice the image becomes almost invisible, but don't worry, when it's pasted on top of the dark city sky, it'll look like it was before. The moon was also a bit too bright, it stood out from the image too much. Again I used colourise to give it the dull blue look. Finally I copied the six phases of the moon that I needed onto the image, saving the image as 1.jpg to 7.jpg as I went (0.jpg is the original - no moon). I have these in a folder on my home directory along with the scripts.
The last step was finding a way to take the output from the moon phase script and assign a picture accordingly. It was here that I found that bash didn't like me ('if' statements were the main cause). Eventually the problem was solved by not using them and editing the moon phase script as mentioned near the start. The end result was rather simple:
#!/bin/bash
phase="`php Moonphase`"
gconftool-2 --type string --set /desktop/gnome/background/picture_filename /home/newage3680/.Background/$phase.jpg
I then set it up to execute this script on startup (actually I had some issues with that, i had to make another script in my home directory that in turn executed this script). The end result suits my theme, so I like it.
If you're interested in using this, here's everything you need (50mb): http://www.mediafire.com/?zfql60f12qdhlj1
Remember, you will need to modify the Moonbackground.sh script so it points to the correct directory and add it to the startup programs so it updates.
And here is the Gimp .xcf image file, everything is seperated into layers (11mb): http://www.mediafire.com/?m6smgmsst641eab
- Login to post comments