From my Notebook >

How to Change XFCE Wallpaper from the Command Line or Terminal

Would you like to change the XFCE wallpaper from a command or script? It’s pretty simple once you go through the right steps.

Note: This is an intermediate-advanced tutorial. It is not meant for beginners.

Find out the correct Properties, including the XFCE workspace number

First, you need to get the “property”, which includes the workspace you’ll be assigning the wallpaper.

If you do not yet have xfconf-query installed, you will need to install it first, via your package manager.

Open a terminal window on your desktop. Then run the following command, and then set the wallpaper for the desktop. You should see the “property” printed in your terminal window, when the change happens:

xfconf-query -c xfce4-desktop -m

Now set the desktop wallpaper. (You can press ctrl-c to quit xfconf-query when finished.) The property should look like this:

/backdrop/screen0/monitor0/workspace0/last-image

Then you can change the wallpaper using this command format:

xfconf-query -c xfce4-desktop -p property_goes_here -s path/to/imagefile.jpg

The Property should contain workspaces 0-7 if you have 8 workspaces.

Example Command

Here is an example of a working wallpaper change command, including Property:

xfconf-query -c xfce4-desktop -p  /backdrop/screen0/monitor0/workspace0/last-image -s /home/username/Pictures/Mountains.jpg

Example Script

Here is a final script example.

In this example you can see the use of the commands find, shuf, and head. This script will select a random wallpaper and then set Workspace 0 to use that wallpaper.

#!/bin/bash
## Pick a random wallpaper...
# Change the below to the correct username, path, etc.
RANDFILE=$(find /home/username/Pictures/ -type f -name "*.jpg" -o -name "*.png" -o -name "*.jpeg" -o -name "*.webp" | shuf | head -n 1)
## Make the wallpaper change
# Change the below if you want to change a different workspace.
# The first workspace is always workspace 0, not workspace 1.
xfconf-query -c xfce4-desktop -p  /backdrop/screen0/monitor0/workspace0/last-image -s "${RANDFILE}"
 

In my system I bound this script to a keyboard shortcut in the Keyboard settings. This way, whenever I want a new wallpaper, I can hit the keyboard shortcut and instantly see the wallpaper change.

I hope that helps! Have fun.