Daily Ubuntu / Linux news and application reviews.

ads

There are maybe hundreds of applications which you can use to automatically change your desktop wallpaper, but is it worth using an application for such an easy task? You can do this with a 3 lines bash script. Let's get started!

Create an empty file anywhere you want. I've created a folder in my home directory, called "scripts" where I place all my scripts so you can do the same. Name this file whatever you want, but in my example I am going to name it "wallpaper.sh" and paste the following code inside this newly created file:

#!/bin/bash

# Script to randomly set Background from files in a directory

# Directory Containing Pictures
DIR="/home/username/Pictures/background"

# Command to Select a random jpg file from directory
# Delete the *.jpg to select any file but it may return a folder
PIC=$(ls $DIR/*.jpg | shuf -n1)

# Command to set Background Image
gconftool -t string -s /desktop/gnome/background/picture_filename $PIC

(Credits for the script: Derek S @ubuntuforums.org)

As you can see, there are just 3 actual commands in the script, the rest are comments. Change the highlighted text (/home/username/Pictures/background) with the exact patch to where you keep your wallpapers.

Now all you have to do is create a cron job to execute the script at a given interval you want. You can use Gnome Schedule for this, which is a GUI for cron.

If you want to download a few hundreds wallpapers with a single command, see THIS post. Make sure you download them in the folder you have set up in the bash script you have created.

If you want to use an application for automatically changing wallpapers in Linux, instead of this script, here are just a few such applications we have written about:

Wally: Best Automatic Wallpaper Changer Application I've Seen [Windows, Linux, Mac OSX]
Automatically Change The Wallpaper Under Gnome with Desktop Drapes
Install Wallpaper Clocks In Ubuntu Linux
«
Next
Newer Post
»
Previous
Older Post