Topic: Rotating desktop wallpapers
In response to this forum post, I wrote and packaged a little script tonight which will rotate desktop wallpapers from a given directory of images. The script can be called in place of Nitrogen in Openbox's autostart file, or better still, it can be called via a crontab entry; when called via cron it turns your desktop into a nifty image slideshow.
The script works by analysing the user supplied directory looking for image files (jpgs and pngs), it counts the number of images in the directory and then displays the first image before saving a count for the next time it runs. The next time the script is called, it reads in the count and displays the next image, provided the same directory was given.
For example, imagine I have a directory containing photographs of my favourite Muppet characters. The directory is located at ~/images/muppets, so I call the script with the following command:
rotate-wallpaper --path ~/images/muppetsWhen I want to change my wallpaper to the next image in the directory, I simply run the above command again.
As mentioned at the beginning, the script works really quite well when used as a crontab entry. Following the example above, I would create a new crontab entry with the following terminal command:
crontab -eI would then type in my command as below and save my crontab file:
*/5 * * * * DISPLAY=:0.0 rotate-wallpaper -p ~/images/muppetsMy desktop wallpaper would now be set to automatically rotate every 5 minutes.
As I mentioned, I have packaged the script and it is available via CrunchBang's repository. It can be installed with the following terminal command:
sudo apt-get update && sudo apt-get install rotate-wallpaperNotes:
I have only done limited testing on my own system. It would be good if others would test the script and provide feedback/bug reports.
The script interacts with Nitrogen and all images are scaled.
I did not spend too much time writing or perfecting the script and I am sure it can be optimised. In fact, knowing there are a gazillion different ways to skin a penguin in Linux, I suspect the script could probably be reduced to 1 line.
Anyhow, the script can be inspected here. Please feel free to use the pastebin to modify and improve.
I hope someone finds this useful and/or fun. ![]()
Last edited by corenominal (2009-04-29 07:08:55)
