Fedora 8 introduced a nice feature which is automatically changing wallpaper relatively to daytime. Here’s how to have this cool feature in Ubuntu (and any other linux distribution) !
Select four wallpapers, one to be displayed at sunrise, the second during the day, third at sunset and the last at night.
Then, in a terminal, create a bash script as follows :
You’ll get the newly created .change.sh file opened in a text editor.
Copy the following text in the file (Change the PATH-TO-**-PICTURE with the appropriate path) :
case “$HOUR” in
gconftool -t string -s /desktop/gnome/background/picture_filename PATH-TO-SUNRISE-PICTURE
gconftool -t string -s /desktop/gnome/background/picture_filename PATH-TO-DAY-PICTURE
gconftool -t string -s /desktop/gnome/background/picture_filename PATH-TO-SUNSET-PICTURE
gconftool -t string -s /desktop/gnome/background/picture_filename PATH-TO-NIGHT-PICTURE
As you can tell, this script sets the appropriate picture depending on the system’s current hour.
Now we’ll create a cron job, which is a linux way to automatically run tasks.
This will open the text editor to edit our cron job.
Copy the following in the text editor (Replace YOUR-HOME-FOLDER by your home folder’s absolute path):
* 4,8,16,19 * * * YOUR-HOME-FOLDER/.change.sh
As you see, the cron task will lauch our previously created script at 4am, 8am, 4pm and 7pm to set the adequate wallpaper.
(Of course, you can change the hours at your convenience).
Now, let’s add these tasks to our gnome session so that they are automatically launched every time we login.
Open the System>Preferences>Sessions menu.
* Click the Add Button
Name: Changing Wallpaper Cron
Command: crontab PATH-TO-YOUR-HOME-FOLDER/.change.cron
Now the job of automatically changing wallpaper is set as an automated job every time we login.
We also have to add the script at session startup so that the correct wallpaper is initialized when we login. (This means, that if you login at e.g. 5:30pm, you’ll have the right wallpaper for that time). To do that,
* Click again the Add Button
Name: Initializing Wallpaper
Here you are ! Your desktop wallpaper is living and reflecting the daytime!