Registered Member
|
There are many forum threads on this topic - how to change KDE4 wallpaper from a script.
Some of them are outdated, other say plasma doesn't support yet this via an interface... http://ubuntuforums.org/showpost.php?p= ... stcount=14 So, my question is: What is the latest and correct way to change the wallpaper given its path? Is it still editing plasma-desktop-appletsrc file? Is there and dbus method for this? Other? |
Administrator
|
At this time there is still no possible method to change the wallpaper from a remote script. The fully Plasma integrated and runtime way to change it is by using a Plasma script, which is written in Javascript.
Unfortunately, for security reasons, external applications cannot yet run scripts. However, they are able to cause the script runner to come on screen, and be preloaded with a script from a file.
KDE Sysadmin
[img]content/bcooksley_sig.png[/img] |
Administrator
|
If you have 4.6 the best way is to make a wallpaper of a fixed name (e.g. "wallpaper.png") then if you want to change a wallpaper, rename the one picked by your script to that name. Plasma will detect the file change and display the new wallpaper.
The only other way is a hack involving QMetaObject's invokeMethod() which is a terrible hack and IMO not future-proof.
"Violence is the last refuge of the incompetent."
Plasma FAQ maintainer - Plasma programming with Python |
Registered Member
|
Thanks to the help above I was able to change this.
My screen is 1440x900. I downloaded one wallpaper 1920x1080- a mountain And one wallpaper 1440x900- a beach. I renamed the "lovelock.png" file in the folder /usr/share/kde4/apps/ksplash/Themes/Lovelock/1920x1200/lovelock.png as "lovelock2.png" Using GIMP I saved the 1920x1080 mountain wallpaper as "lovelock.png" here: /usr/share/kde4/apps/ksplash/Themes/Lovelock/1920x1200/lovelock.png I left its size as 1920x1080. And I saved the 1440x900 beach wallpaper here /usr/share/kde4/apps/ksplash/Themes/Lovelock/1440x900/lovelock.png I left it as 1440x900. I had to create the new folder "1440x900" as there was not one. After reboot the beach wallpaper appeared on screen. It was a bit blurry as its resolution did not match my screen. After 10 seconds it was replaced by the 1440x900 beach scene, sharply displayed in the correct resolution. So I am surprised that such a popular feature is so hard to change. But at least it can be done. Thanks |
Registered Member
|
I just did a script to change wallpaper and it works:
I gets current activity id and finds all containments that match it, replacing wallpaper setting entry in them, stops plasma, saves the config and starts plasma. I my plasma-desktop-appletsrc file there are two containments for the current activity id:
and the output of the script is:
I need your comments on the idea and the code. Also, i guess, it would be nice to change the wallpaper only for the current screen? Should change wallpaper settings only for the containment with `screen` setting that matches the result of dbus.Interface(kwin, 'org.kde.KWin').currentDesktop() call? But in my case it returns 1 while in the settings it's 0 for my current desktop. How to find the current `screen` number that is the same as the one in plasma settings? |
Registered users: Bing [Bot], Google [Bot], Yahoo [Bot]