How to set the wallpaper in KDE from the command line


dbus-send \
  --session \
  --dest=org.kde.plasmashell \
  --type=method_call /PlasmaShell org.kde.PlasmaShell.evaluateScript \
  'string:
    const Desktops = desktops()

    for (let i=0; i<Desktops.length; i++) {
      const d = Desktops[i]
      d.wallpaperPlugin = "org.kde.image"

      d.currentConfigGroup = Array(
        "Wallpaper",
        "org.kde.image",
        "General"
      )

      d.writeConfig(
        "Image",
        "file:///page/to/image.jpg"
      )
    }
  '