Automatically changing wallpaper relatively to daytime in Ubuntu
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) :
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 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):
As you see, the cron task will launch 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
- Click Ok
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 so:
- Click again the Add Button
- Name: Initializing Wallpaper
- Command: PATH-TO-YOUR-HOME-FOLDER/.change.sh
- Click Ok
Here you are ! Your desktop wallpaper is living and reflecting the daytime! :P
Feel free to send your comments if you have any issue.