How do I set the KDE desktop wallpaper (jpg file) from command line (e.g., by a script, started by the user)?

3 Answers 3


Sadly, there doesn't seem to be a simple way.

It appears you need to do something like this (from https://www.kubuntuforums.net/showthread.php/66762-Right-click-wallpaper-changer?p=387392&viewfull=1#post387392):

qdbus org.kde.plasmashell /PlasmaShell org.kde.PlasmaShell.evaluateScript 'var allDesktops = desktops();print (allDesktops);for (i=0;i<allDesktops.length;i++) {d = allDesktops[i];d.wallpaperPlugin = "org.kde.image";d.currentConfigGroup = Array("Wallpaper", "org.kde.image", "General");d.writeConfig("Image", "file:///media/sda2/Background/SpaceWall/Escape_Function.jpg")}'

or, another example, formatted more nicely (adapted from https://github.com/bharadwaj-raju/libdesktop/issues/1:

qdbus org.kde.plasmashell /PlasmaShell org.kde.PlasmaShell.evaluateScript '
    var allDesktops = desktops();
    print (allDesktops);
    for (i=0;i<allDesktops.length;i++) {{
        d = allDesktops[i];
        d.wallpaperPlugin = "org.kde.image";
        d.currentConfigGroup = Array("Wallpaper",
        d.writeConfig("Image", "file:///path/to/imagefile")

I also found a pythonic solution.


As this Reddit comment states:

#!/usr/bin/env -S bash

path_to_wallpaper = '/path/to/file.png'                            # The path to the wallpaper
kwriteconfig5                                                    \ # The configuration tool
  --file "$HOME/.config/plasma-org.kde.plasma.desktop-appletsrc" \ # The path to the configuration file
    --group 'Containments'                                       \
      --group '1'                                                \
        --group 'Wallpaper'                                      \ # This can alternatively be a colour
          --group 'org.kde.image'                                \
            --group 'General'                                    \
              --key 'Image' "$path_to_wallpaper"                   # The key which contains the path to the wallpaper

However, note that in its current form, that answer solely applies to cpe:/a:kde:plasma:5 - cpe:/a:kde:plasma:6 necessitates that kwriteconfig6 be utilized, whose syntax may differ.


Just run this in a script to solve all your problems:

Using Chris' solution:

This is an elaborate answer, however I solved my problems by building on Chris' solution, and I find it far better then KDE's built-in wallpaper functionality - which only works on a single monitor.

Works on all monitors - Just change the variables sleeptime AND location at the top - Copy/Paste into a .sh file and run it.

while true

# //// CONFIGURABLE VARIABLES ////////////

# pausetime between iterations
# location of wallpapers folder

# ////////////////////////////////////////

array=($(ls $location*)) # populate array with directory contents
( IFS=$'\n'; echo "${array[*]}" ) # list array content for debug

index=$(($RANDOM % $size)) 
wallpaper=${array[$index]} # randomly select

echo " || SELLECTED WALLPAPER = "$wallpaper

dbus-send --session --dest=org.kde.plasmashell --type=method_call /PlasmaShell org.kde.PlasmaShell.evaluateScript 'string:
var Desktops = desktops();                                                                                                                       
for (i=0;i<Desktops.length;i++) {
        d = Desktops[i];
        d.wallpaperPlugin = "org.kde.image";
        d.currentConfigGroup = Array("Wallpaper",
        d.writeConfig("Image", "file://'''$location'''/'${wallpaper}'");
sleep $sleeptime


I run this as a startup script and I never have to worry about it again. The cool thing about it is that the array variable which contains all wallpaper filenames - repopulates on every loop, which means I can change my wallpaper loadout and have that reflected in the scripts operation.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .