I recently wrote this simple script to allow me to set a random image as my background:
#!/bin/bash
# Selects a random jpeg file in the ~/backgrounds/ directory (or it's
# sub-directories) and makes it the background image.
file_list=`find ~/backgrounds/ -name *.jpg`
num_files=`echo $file_list | wc -w`
ran_line_number=$(($RANDOM% $num_files+1))
selected_file=`echo $file_list | tr " " "\n " | sed -n ${ran_line_number }p`
display -backdrop -window root $selected_file
On most light-weight window managers, like Blackbox, simply copy any images you want to use as backgrounds into ~/backgrounds/ and you're good to go. Some other Window Managers/Desktop environments look after the desktop background themselves so you would have to disable that in their configuration first. If you wanted to run this every half hour or something you could put it in your crontab, or else you can just set it up so it runs when you start your window manager.
Posted by Timothy Pollard in Linux
Computers on August 06, 2008
Comments