How to set wallpaper background color in command line?

Although it is possible to set the wallpaper through the command line I was unable to find an option for the background

usr_40476@localhost:~> 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

I’m pretty sure this isn’t implemented yet.

hmmm, I’m going to do something a have never done before, contribute. (where is the repo? – or am i understanding this wrong?)

1 Like

That’s great!

The code for the plasma-apply-wallpaperimage binary lives at wallpapers/image · master · Plasma / Plasma Workspace · GitLab. Based on the name of the binary, you can tell it’s intended only for applying images.

So my recommendation would be to clone it and create a new plasma-apply-wallpapercolor tool that lives at wallpapers/color · master · Plasma / Plasma Workspace · GitLab.

1 Like

hmmm, I see, but where is the code for changing the background color that the gui uses?

also i’m afraid I may have broken the sign up process and seem to have borked my email as I cannot get my password reset to work with either of my emails

If you need help logging in, you can always email to explain the situation. They’ll help you out.

Thank you, I just did that,
Please can you point me towards where is the code for changing the background color that the gui uses?

It’s in here:

The code is declarative rather than imperative, so if you’re looking for something that says

if (wallpapercolor) {
    return 0;

Then that would be why you aren’t finding it. :slight_smile:

What the code in that file is doing is instantiating a WallpaperItem object, which is the base class for wallpaper subclasses. Then that object is completely filled with a Rectangle whose color comes from the value of root.configuration.Color, which is set by the user in wallpapers/color/contents/ui/config.qml · master · Plasma / Plasma Workspace · GitLab. This colored rectangle is then used as he wallpaper.

So your command-line program will need to set the value of the Color configuration string.

I have to add the method to change wallpaper changed between Plasma 5 and plasma 6.
wallpapers/image/plasma-apply-wallpaperimage.cpp · master · Plasma / Plasma Workspace · GitLab has not been updated yet.
In Plasma 6 (which you should target), you can pass any wallpaper setting using dbus, this should make your implementation simpler.
You can see an example at shell/tests/setwallpapertest.cpp · master · Plasma / Plasma Workspace · GitLab
Pass org.kde.color and pass your color settings in the params QVariantMap.

I think i forgot to mention that this is my first time with C or C++, so I may have walked into a bit of a situation, but I am determined to make it a learning opportunity, could some guide me though the proccess?
I have programming knowled in javascript and that is about it but I wanted to be better at the skills that I would need to work on/add features I was curious about