Not sure if I should be posting in Linux section, but this section of the forum seems to be more active.
Can anyone offer any pointers about setting the background (wallpaper) image on a KDE desktop using PB?
TIA
Dave
Set KDE Desktop Background?
Set KDE Desktop Background?
Last edited by davebar on Thu May 09, 2019 2:02 pm, edited 2 times in total.
Re: Set KDE Desktop Background?
The only way to do this is by dbus and with scripting:
And it doesn't work if widgets are locked and does not throw an error in this case.
But it its the official way. You can utilize it with PBs RunProgram() command.
Otherwise you can search files under ~/.config with plasma in their name, the setting should be stored there somewhere.
But if you use this, the wallpaper won't change till KDE is forced to parse the config files again. Also there is no guarantee that the setting will have the same name in future versions (but it is likely).
Code: Select all
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",
"org.kde.image",
"General");
d.writeConfig("Image", "file:///PATH/TO/IMAGE.png");
}'
But it its the official way. You can utilize it with PBs RunProgram() command.
Otherwise you can search files under ~/.config with plasma in their name, the setting should be stored there somewhere.
But if you use this, the wallpaper won't change till KDE is forced to parse the config files again. Also there is no guarantee that the setting will have the same name in future versions (but it is likely).
Re: Set KDE Desktop Background?
Thanks macros, pity there is not a simple 1 line api call like windows, but your solution works perfectly for me.
Re: Set KDE Desktop Background?
Seems I spoke a little to soon. What I should have said is that it works perfectly, but ONLY ONCE.
If I change the image file name in the script and run it again the wallpaper doesn't change.
What I need is to find is a way to force KDE to parse the config files again. Any thoughts?
TIA
If I change the image file name in the script and run it again the wallpaper doesn't change.
What I need is to find is a way to force KDE to parse the config files again. Any thoughts?
TIA
Re: Set KDE Desktop Background?
I found my own workaround (nasty kludge), which was to create a second almost identical script.
My code then uses RunProgram("bash", "./script1.sh", Directory$, #PB_Program_Wait) to run script1 which points to a blank jpg image and then uses RunProgram("bash", "./script2.sh", Directory$, #PB_Program_Wait) to run script2 which points to the valid png image.
Why this works I have no idea and probably nauseates coding purists, the only important thing for me is that it does do what I need.
My code then uses RunProgram("bash", "./script1.sh", Directory$, #PB_Program_Wait) to run script1 which points to a blank jpg image and then uses RunProgram("bash", "./script2.sh", Directory$, #PB_Program_Wait) to run script2 which points to the valid png image.
Why this works I have no idea and probably nauseates coding purists, the only important thing for me is that it does do what I need.
Re: Set KDE Desktop Background?
Interesting workaround, thanks for sharing it.
I hope one day KDE devs integrate a direct dbus call for this.
I hope one day KDE devs integrate a direct dbus call for this.