Little Girl's Mostly Linux Blog


Wallpaper Changer

This page was last updated on October 17, 2015.

Wallpaper Changer

This is a Bash script you can put in your Linux Mint MATE startup list to automatically change your wallpaper randomly from the images in the specified directory at the specified interval.

  1. Copy these contents into a text editor:
    # This script randomly sets the wallpaper from files in the specified directory.
    # Note: Files may have spaces in their names.
    # The following line sets up an infinite loop that will run continuously:
    while true; do
    	# The following line specifies a directory that contains images for use as wallpaper. Edit the line, replacing /PATH with the full path to the directory you wish to use:
    	# The following line looks in the specified directory to find all files that end in .gif or .jpg or .jpeg or .png (case insensitive) and then shuffles them and randomly chooses one of them and saves its full path as the result:
    	RESULT=$(find "$LOCATION" -iregex ".*\.\(gif\|jpg\|jpeg\|png\)" -type f | shuf -n1);
    	# The following line sets the wallpaper using the chosen file:
    	gsettings set org.mate.background picture-filename "$RESULT";
    	# The following line waits the specified number of seconds after changing the wallpaper. Edit the line, choosing the length of time you'd like the wallpaper to remain in place before being changed. 300 = 5 minutes, 600 = 10 minutes, 900 = 15 minutes, etc.:
    	sleep 300
    #The following line is the end of the infinite loop:
  2. Edit the path to point to your directory full of images.
  3. Edit the sleep line to use the number of seconds you’d like the image to display before being changed.
  4. Save the file as WallpaperChanger.bash (or whatever name you would like the file to have) in the directory you keep scripts in (creating one if you like).
  5. Open a file manager in the directory you just put the file into.
  6. Right-click the file.
  7. Choose Properties from the context menu.
  8. Left-click the Permissions tab.
  9. Left-click inside the box next to “Allow executing file as program”.
  10. Left-click the close button.
  11. Close the file manager.
  12. Open the System menu.
  13. Choose the Preferences sub-menu.
  14. Choose Startup Applications.
  15. Left-click the Add button.
  16. Type the name you’d like the wallpaper changer to have in this list so you will recognize it if you come back here another time (example: Wallpaper Changer).
  17. Left-click the Browse… button.
  18. Browse to the script file you saved above.
  19. Left-click the Open button.
  20. Type a comment describing what the script does if you like (this is optional).
  21. Left-click the Add button. You should now see the script you just added in the list of startup applications.
  22. Left-click the Close button.

Now when you boot your computer the script will run, immediately choosing a random wallpaper for you, and randomly changing it to a new one at the interval you specified until you end the process or shut down the computer.

Obligatory Happy Ending

And they all lived happily ever after. The end.

Create a free website or blog at

%d bloggers like this: