Linux Tutorials Wallpapers

How to Automatically Change Wallpapers on Ubuntu

How to Automatically Change Desktop Wallpapers on Ubuntu

The latest GNOME already has a feature that automatically changes the wallpaper throughout the day very much like Windows 10. Since GNOME is the default desktop in Ubuntu now, this feature is available on Ubuntu by default. However, unlike Windows 10, there isn’t a feature that allows you to automatically change wallpapers from your own collection. Not without the help of a third-party script or tool at least. In this case, the third-party script you will need is called LittleSimpleWallpaperChanger or LSWC that lets you automatically change wallpapers on Ubuntu.

LSWC is a small, very light-weight script that runs in the background and it will automatically change wallpapers from the user-specified folder. The wallpapers are set to change at random intervals between 1 to 5 minutes. The setup is pretty easy and once done, you can forget about the script. Before you start with the installation though, you should probably create a folder containing all the different wallpapers that you want to switch amongst. Make sure all the images are in jpg or jpeg format because only those are supported.

Download and Install LSWC

  1. You can download the script from this link. This will give you a zip archive file.
  2. Right-click on it and select Extract here.
  3. Open the extracted folder in a terminal. You can do this by launching the Terminal and then navigating to the folder using the cd command or by opening the folder in Nautilus, right-clicking an empty space and selecting Open in Terminal.
  4. Regardless of how you open the folder inside a Terminal, once you do, copy and paste this command in the Terminal and hit enter.
    bash ./README_and_install.sh How to Automatically Change Desktop Wallpapers on Ubuntu
  5. A dialogue box should now appear asking you to locate the folder that you want to use as your wallpaper source. Click on it and select the folder where you’ve kept your selected wallpapers. If you prefer you can set the Wallpapers folder in Pictures as the source folder. Any images that you set as wallpaper are automatically transferred to this folder. This means you can easily add to your collection by simply setting an image as the wallpaper.
  6. The script starts working right away as soon as you select the folder. If it doesn’t, try rebooting the computer.

Don’t miss these:

How to use LSWC

During installation, you have already selected the source folder for wallpapers. You can still add or remove wallpapers from this folder and the script will continue to switch between available images. However, you can’t now change the name or location of the selected folder as you please. That’ll break the script, for obvious reasons. If you want to change the source folder or rename it, you’ll need to edit a file named homepath.conf found in /home/.config/lswc/. You may have to press Ctrl+H in your home folder to see the .config folder. Navigate to the file and double-click on it to open it.

How to Automatically Change Desktop Wallpapers on Ubuntu

The file contains nothing but the path to your selected source folder. You can edit and save the file anytime you want to change the location.

Update

Another way you can do this is by simply deleting the homepath.conf file and running the script again.

How to Automatically Change Wallpapers on Ubuntu

The time interval before wallpapers are changed can also be modified. To do that, open the lswc file in a text editor and scroll down all the way to the bottom. Look for the following line.

loop_run = round((random.random() * 4 ) + 1) * 60

To change the time interval, just change the + 1 to + 2 or + 3 etc. Below that, you’ll find the line sleep(loop_run). This can also be modified to something like sleep(1), sleep(2) or sleep(3) etc.

Compatibility

Compatibility is something one kind of has to worry about on Linux. There are so many distros that can be quite different from each other and just as many desktop environments. LSWC is based on GTK so it should work not only on Ubuntu but any Linux distro as long as it uses GNOME desktop. The GitHub repos also contain specific versions for Lubuntu 18.04 and MATE 18.04 if you prefer the Lubuntu or MATE desktop environments over GNOME.

How to remove LSWC

If you decide you don’t need all the pre-defined randomness on your desktop, say you find a wallpaper you want to keep for a while, you’ll need to remove LSWC. For this, first, stop the script with the following command.

pkill lswc

With hidden files visible in your home folder (press Ctrl+H if they aren’t) navigate to and delete the following files and folders from the mentioned folders.

  • scripts folder from .local
  • lswc folder from .config
  • lswc.desktop file from .config/autostart

That’s pretty much all you have to do.

3 Comments

  • For the writer of this article, Thank you for posting this 🙂

    I do have a few alterations for you to make please.

    Regarding ‘{However, you can’t change the name or location of the selected folder. That’ll break the script, for obvious reasons. If you want to change the source folder, you’ll need to edit a file named homepath.conf found in /home/.config/lswc/.}’ I can enlighten you with the right solution, build in from the beginning, also explained in the README-installer:

    Just remove the file ‘homepath.conf’ or the complete folder it’s in. Then wait for the dialog (still that random time) to appear again to ask you which folder to choose from or to create one, after you have chosen or created a new folder location, the program continues. The script checks every loop for a homepath.conf and the jpg files (you cant break it 🙂

    And — ‘{For now, there’s nothing you can do about the random time duration before wallpapers are changed.}’ — One can however change the third line from the bottom ‘ sleep(loop_run)’ in sleep(10) or sleep(2) or change the line above it ‘loop_run = round((random.random() * 5 ) + 1) * 60’ with different numbers, +1 can be +2 or +10 (if you like a longer interval than 6 minutes)

    For other questions or comments, follow the email-address or tweet-handle in the readme/installer. I will be happy to answer your question.

    Regards, Ronald..

      • I realy love what you made of it, also love your blog! one correction though, you state: “Another way you can do this is by simply deleting the homepath.conf file and running the script again.” – that is not correct, one can remove the ‘homepath.conf’ also while the script runs. It sleeps whilst the cycle of random unfolds, and then represents the dialogue again, which folder to choose … no need to stop or start the script. ** The only way it kills its self is when the chosen folder is empty, then is has nothing to do .. en dies. Then add some jpgs and run it again ( python3 ~.local/scripts/lswc/lswc )

Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.