How to set KDE desktop wallpaper from command line?

5

1

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

basic6

Posted 2012-10-15T20:20:08.917

Reputation: 2 032

Answers

2

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",
                                     "org.kde.image",
                                     "General");
        d.writeConfig("Image", "file:///path/to/imagefile")
    }}
'

I also found a pythonic solution.

Chris

Posted 2012-10-15T20:20:08.917

Reputation: 129