I'm currently running a computer that uses Fedora Linux, with the spin that comes with KDE Plasma as the desktop (I happen to prefer that to Gnome).
I wanted a script that will download a desktop wallpaper from the internet, and then set that to be my current wallpaper.
I have searched the web for the best way to do this, and hit advice that is outdated or inaccessible. Outdated, because it's many years old and things have moved on. Inaccessible because it seems the link in Google's index to every URL in the KDE forums is a broken link (they must have restructured their forum and not set up redirects), and because the KDE Reddit r/kde is private and I can't view the pages that come up in search.
So, for the benefit of others, here's what I've found.
You don't need to use qdbus
The reason you don't need that is that you can just call /usr/bin/plasma-apply-wallpaperimage. It just does the job out of the box, and you can pass in relative paths too.
$ plasma-apply-wallpaperimage --help
Usage: plasma-apply-wallpaperimage [options] imagefile
This tool allows you to set an image as the wallpaper for the Plasma session.
-h, --help Displays help on commandline options.
--help-all Displays help including Qt specific options.
imagefile An image file or an installed wallpaper kpackage that you wish to
set as the wallpaper for your Plasma session
So you literally just call
and it works.
You need a unique filename
Or, at least, it nearly works.
If you run that command once, it will indeed change your wallpaper.
If you download another picture to my-wallpaper.jpg, and run it again, nothing changes. If you then right click on your desktop to pull up the dialog where you'd manually set the wallpaper, your new picture is there in the dialog, but nothing changes until you log out and log back in. Which I don't want to have to do.
It turns out that if you run plasma-apply-wallpaperimage with the same filename you used before, the system assumes the picture hasn't changed, so the change is not fully applied.
So all you need to do is download your filename so the filename is not identical to the one you had before. And then it will work.
wget $URL -O wallpaper-$DATE.jpg