Home > Linux, Ubuntu > My Ubuntu Background Changing Script

My Ubuntu Background Changing Script

I am an indecisive person. To the extreme. Naturally this personal trait lead to some issues when I decided that I wanted to change my background image on my Ubuntu laptop.

When I started looking I found no lack of Linux and Ubuntu related wallpapers available and came across many that I liked. I saved all the images to a directory, settled on one, and sat back to enjoy my newly decorated desktop. Little did I realize that approximately thirty minutes later I would be changing it again. Before long I came to the conclusion that, left to my own compulsions, I would be manually changing my background image at an annoying rate forever. I’m no scripting guru by any stretch so this situation seemed like a great opportunity to learn and solve a problem at the same time.

The script is designed to check a designated directory for image files to use as your desktop background. You can use the Ubuntu default of /usr/share/backgrounds or set a custom location in the configuration area at the beginning of the script. Once a list of the available images is generated it will pick a new one to set. Finally it will check to make sure that the new background is not the same as the current one, if it is another will be selected; if not the new background will be set.

To automate the process you simply need to add a cron job to handle running the script. For example, if you wanted your background image to change every ten minutes you would add the following line to crontab:

1-59/10 * * * * /path/to/the/script

To find out more about scheduling cron jobs, or cron in general, Google is your friend.

If anyone has questions, tips, code improvements, etc. please feel free to leave comments!

Script code can be found here!

Advertisements
Categories: Linux, Ubuntu
  1. No comments yet.
  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: