How Can I change wallpaper from CLI?


Sorry to brother,I don not know which channel should i send this mail exactly , so i send this mail to kde, kde-devel and ode-core-devel, but i really need this help, please

i am a developer of an application which can do browse online gallery and change the desktop wallpaper。You can find it at (<a href="" title=""></a>)

but when i tried to support KDE I cannot find a possible way to change the wallpaper in CLI such like ( kde-wallpaper set <a href="//xxxxx" title="//xxxxx">file://xxxxx</a> )

Please give me some tips about this

Thank you


Re: How Can I change wallpaper from CLI?

By Duncan at 09/06/2012 - 05:46

kevinzhow posted on Wed, 05 Sep 2012 21:48:47 +0800 as excerpted:

[sent to the general list only]

You don't say much about project parameters and I can't read Chinese or
whatever that is on the above site. I see in the other subthread you
mention OpenSuSE. Are you targeting that specifically, or all distros?
Are you familiar with dbus? What about the apps dbus-send, qdbus (both
cli), and qdbusviewer (gui)? What about the plasmoid (kwallpaper-changer
or whatever it was, on google code) mentioned in the comments to the post
linked in the other subthread? In addition to using it directly, if you
know python, presumably you could read its code (it's python based, using
PyKDE, it looks like) and make similar calls from your own python script.

Here I'm reasonably handy with bash scripting, but not a lot more. If I
were trying to change the wallpaper from a bash script and couldn't
simply install the wallpaper-changer plasmoid and use it, I'd try the
following approach, obviously poking and adjusting and learning and
perhaps getting frustrated a lot as I went until I had it doing what I

I'd use the dbus interface (probably ultimately dbus-send from the
script) to org.kde.ActivityManager to get the current activity, then
check $KDEHOME/share/config/plasma-desktop-appletsrc[1] for that
activity, looking for the appropriate wallpaper sections (note that there
may be multiple desktop containers if the user has multiple monitors,
each with its own wallpaper and thus wallpaper sections, but at least as
of kde 4.9, all part of the same activity) and editing them accordingly.
Then I'd make the appropriate dbus call to either plasma-desktop or to
kded to trigger a config-changed event so it would reread the file.

Of course some users use plasma-netbook instead of plasma-desktop. I
don't know what config files it uses, but presumably you could figure
that out, edit that instead of plasma-desktop-appletsrc, and call its
reload-config trigger, if it's running instead of plasma-desktop.

[1] The $KDEHOME path defaults to ~/.kde as shipped by kde, if the
variable isn't set, but many distros change that to ~/.kde4, and of
course the user can set $KDEHOME in kde's environment to change it to
whatever filesystem location they wish. So if you're aiming for a
specific distro you can use their path if the var isn't set, or check and
see which one of the two exists if aiming for wider audience.

Re: How Can I change wallpaper from CLI?

By Kevin Krammer at 09/06/2012 - 06:41

Apparently triggering config reparsing wouldn't be sufficient since the config is
not processed again.

In any case, the thread spawned on the developer lists mentions that there is
a D-Bus interface for that kind of task in the works.

kde4-config --localprefix

or kwriteconfig when manipulating KDE config files from commandline or script.


Re: How Can I change wallpaper from CLI?

By Nowardev-Team at 09/05/2012 - 10:10

you can try with this

<a href="" title=""></a>

2012/9/5 kevinzhow <kevinchou. ... at gmail dot com>

Re: How Can I change wallpaper from CLI?

By kevinzhow at 09/05/2012 - 11:01

I had tried this but ..... The xdotool package has not been included in opensuse

And this workaround may will cause more problems in someway

在 2012-9-5,下午10:10,Nowardev-Team < ... at gmail dot com> 写道:

Re: How Can I change wallpaper from CLI?

By Weng Xuetian at 09/05/2012 - 10:23

On Wed, Sep 5, 2012 at 9:48 AM, kevinzhow <kevinchou. ... at gmail dot com> wrote:
KDE can have multiple activity, and every activity can have different
wallpaper (even different plugin). And wallpaper is supported via
plasma plugin.
So I would suggest you to implement a wallpaper plugin to do this,
which can even gives you more freedom for control.

Some tutorials are here.
<a href="" title=""></a>

Otherwise you can only use some hack way to modify kconfig
(kwriteconfig / kreadconfig via CLI, or using code) . I'm not sure
which key will work for the default plugin.

CC plasma-devel.

Re: How Can I change wallpaper from CLI?

By Tomaz Canabrava at 09/05/2012 - 10:53

2012/9/5 Weng Xuetian < ... at gmail dot com>:
This looks like the KDE Get Hot New Stuff for the desktop wallpaper,
from your screenshoots.
why don't you create a backend for the GetHotNewStuff for your wallpapers?


Re: How Can I change wallpaper from CLI?

By Shaun Reich at 09/05/2012 - 10:55

On Wed, Sep 5, 2012 at 10:53 AM, Tomaz Canabrava < ... at kde dot org> wrote:
there's more to it than just "a source for wallpapers" afict, so i
don't think that's a valid solution.

Re: How Can I change wallpaper from CLI?

By Alexander Neundorf at 09/05/2012 - 13:30

On Wednesday 05 September 2012, Shaun Reich wrote:
This should be possible using wget and some dbus calls, shouldn't it ?


Re: How Can I change wallpaper from CLI?

By Jeremy Paul Whiting at 09/05/2012 - 13:46

On Wed, Sep 5, 2012 at 11:30 AM, Alexander Neundorf < ... at kde dot org> wrote:
No, I don't think any plasma containments expose their configuration on dbus.


Re: How Can I change wallpaper from CLI?

By Alexander Neundorf at 09/05/2012 - 14:10

On Wednesday 05 September 2012, Jeremy Whiting wrote:
In KDE3 it was possible to set the wallpaper via dcop in kdesktop. So we can't
do this anymore ?


Re: How Can I change wallpaper from CLI?

By Thiago Macieira at 09/05/2012 - 14:33

On quarta-feira, 5 de setembro de 2012 20.10.53, Alexander Neundorf wrote:
No. The architecture changed completely and no one has apparently felt the
need to do that in the past 5 years.

Don't forget that there are several containments (different screens, different
activities, etc.) that can show wallpapers.

Re: How Can I change wallpaper from CLI?

By =?UTF-8?Q?Nicol... at 09/05/2012 - 14:35

2012/9/5, Alexander Neundorf < ... at kde dot org>:
In the past, a desktop had a wallpaper. Now, a plasma desktop can have
one or more desktop containments (activities) which may have any
wallpaper plugin which may or may not have the concept of a static
image that you can configure.

Re: How Can I change wallpaper from CLI?

By =?UTF-8?Q?Nicol... at 09/05/2012 - 15:24

2012/9/5, Nicolás Alvarez <nicolas. ... at gmail dot com>:
Apparently you can set a wallpaper like this:

function setWallpaperOnActivity(activity) {
if (activity.wallpaperPlugin != "image") return false;


But there seems to be no DBus method to run JS scripts in Plasma
without using the interactive console dialog...

Re: How Can I change wallpaper from CLI?

By Gilles Caulier at 09/05/2012 - 14:42

There a task assigned to a student this summer to open Plasma API for
wallpaper purpose. I mentored him to patch Plasma and write relevant
Kipi plugin for digiKam.

This code (this patch) for Plasma is not yet integrated to KDE core.
For me, it become urgent that KDE desktop provide this simple and
usefull feature...

For details look here :

<a href="" title=""></a>
<a href="" title=""></a>
<a href="" title=""></a>
<a href="" title=""></a>


Gilles Caulier

2012/9/5 Nicolás Alvarez <nicolas. ... at gmail dot com>:

Re: How Can I change wallpaper from CLI?

By Aaron J. Seigo at 09/05/2012 - 17:26

On Wednesday, September 5, 2012 20:42:55 Gilles Caulier wrote:
honestly, it would make a lot more sense for applications that show content to
use KActivities::ResourceInstance so that applications can see what the active
content is.

what that would do in this case is instead of implementing (non-standard)
means to set desktop wallpapers in N applications, N applications simply start
advertising what content the user is focused on so that other parts of the
system can react.

that way instead of dozens of different plugins for dozens of applications to
do something as inane and rarely used as "set this random image i'm viewing to
be my wallpaper" using a menu item (it's already possible with drag and drop),
Share Like Connect could simply offer an item when a image with a supported
mimetype is selected / viewed.

then nobody needs to worry about plasma shell internals (which can even differ
between shells, btw, and has changed over time in some shells making
maintaining such publicly used dbus APIs a PITA) and nobody needs to keep
writing new plugins for this stuff.

extra bonus is that we'd then be able to do actually useful things for free
like make it simple to post an image to one's microblog account or add the
image (or whatever document / data / information) to an activity or ....

and how hard is it?

using namespace KActivities;
m_resource = new ResourceInstance(window->wId(), this);

... some time later ...



show me a dbus api for wallpaper setting that can do that. :)

Re: How Can I change wallpaper from CLI?

By Kevin Krammer at 09/06/2012 - 06:47

The problem with that (as far as I can tell) is that this would not be
available to non-KDE apps, which (again as far as I understand) is the case of
the thread starter.

D-Bus interfaces have the advantage of being accessible from almost any
program technology stack, most times even from shell scripts.

Just curious: what kind of non-D-Bus communication mechanism is used by that?


Re: How Can I change wallpaper from CLI?

By Aaron J. Seigo at 09/06/2012 - 07:50

On Thursday, September 6, 2012 12:47:16 Kevin Krammer wrote:
if the issue was non-KDE apps, this would be an interesting starting point for

but the discussion moved to the example of a KIPI plugin for digikam. that is
a KDE application.

once we get our own house in order, then i'd love to discuss about how we
interface with the rest of the world.

qdbus org.kde.ActivityManager /ActivityManager | grep Resource

we're smart enough to implement things in ways that aren't completely stupid.

and really this is a design question ("is associating URIs and metadata with
windows a good / better solution? if so, how?"), not an implementation problem
("what is used for remote procedure calls?").

even if the implementation is bad (though i don't believe it is), we can
usefully improve the implementation as long as we have a good design to start
with; the reverse is not true however -> design flaws don't get fixed by
improving the implementation of them.

currently when it comes to things like setting wallpapers, our design sucked.

so some of us worked on improving that, and if you look at its use in Plasma
Active you can judge for yourself whether or not it is an improvement or not.

and now we're asking the rest of our community to use that improved design
broadly including on the desktop.

it uses DBus. the differentiation is that it isn't focused on "making something
to set a wallpaper" but focused on "allowing content to be introspected so
that things can be done for/with that content".

making an API for "setting wallpaper" is not only fragile (see the differences
in KDesktop 1, 2, 3 and Plasma; see the differences for windows, mac, xfce,
gnome, etc) it is also very limited in scope and needs to be upkept in every
single application.

the design concept of "expose the URI of the content this application window
is showing" suffers none of those limitations. and it lets us do the trivial
things like "set that as a wallpaper" easily: it's writing one plugin for one
app (SLC) instead of writing one plugin for every single application out

really, it's the same thinking that went into things like kparts.

Re: How Can I change wallpaper from CLI?

By Kevin Krammer at 09/06/2012 - 08:22

On Thursday, 2012-09-06, Aaron J. Seigo wrote:
Well, the issue is non-KDE apps or at least one of them (the one of the
developer asking on how to do change the wallpaper).

I considered this an additonal data point, i.e. another interested party in
changing wallpapers.
However, if we consider this a new subtopic, then somebody should probably
advise the thread starter on the more generic problem.


Sure. Meaning that someone has to reply to the original query and write that
Plasma workspaces currently do not support programmatic changes of wallpaper
but is something considered for the future.

I didn't say that D-Bus interfaces were the best or even a good solution just
that one of their properties is being usable from a lot of program

Without checking the implementation details I would have guessed that
"allowing content to be introspected" needs support for that introspection in
every single application and that support would need to be updated when the
introspector changes the way it introspects.

Basically moving the maintenance of API from the target to the source of the

However, the thread starter might be willing to provide such introspection
capability if somebody points them to respective interface descriptions.


Re: How Can I change wallpaper from CLI?

By Aaron J. Seigo at 09/06/2012 - 11:03

On Thursday, September 6, 2012 14:22:28 Kevin Krammer wrote:
in the same way that every application that opens files stored on disk needs to
support file open/read/write. in reality, very few of our applications make
direct libc calls to achieve this and instead rely on (much) higher level
libraries to keep such details at arms length.

we don't even need to patch every single application thanks to KDE's
libraries. by patching specific classes in our libs, we are able to get the
functionality in many of our apps instantly. example: we have written and
maintain a rather small patch that makes kparts use ResourceInstance. this
small change in one library makes every single kparts-using application
instantly work as desired. KDE's dev framework is pretty awesome like that.

some applications will require some patches, however. that's already been done
in dolphin (as one example), so we know how dificult it is: not very. these
patches are small and very simple to write (i gave an example code snippet in
a previous email), and only need to be done where other suitable frameworks
(e.g. kparts) are not used.

that's why we have a library like libkactivities: to provide an easy to use,
long-lived API that hides the implementation details. the API in
libkactivities is built around the design ("expose what is being viewed in a
window") not the implementation ("we connect to a daemon using dbus and

the introspection mechanism is completely encapsulated in libkactivities and
no application need (or should) care now or in the future about the
implementation details. in frameworks 5 libkactivities will end up being a Qt-
only library. the dbus API is also available in a well-formed dbus xml service
definition so it can be readily reused by other applications which don't use

so .. no. the individual application should never need to be updated even if
kactivitymanagerd changes, is replaced, or whatever.

Re: How Can I change wallpaper from CLI?

By Kevin Krammer at 09/06/2012 - 12:05

Sure, same as applications dealing with images using the Kipi plugins for
sharing implementations of common tasks.

Excellent, so can any of the developers involved with this effort compile a
list of D-Bus introspection files (probably as links into the repository) for
the thread starter so he can implement the necessary adaptors/interfaces in
whatever technology stack he is using?


Re: How Can I change wallpaper from CLI?

By Michael Pyne at 09/05/2012 - 17:50

On Wednesday, September 05, 2012 23:26:32 Aaron J. Seigo wrote:
Does this actually change the wallpaper for the default containment though, or
is more work still needed on that end? If this is the official method and it
works now I'm sure people wouldn't mind implementing it.

- Michael Pyne

Re: How Can I change wallpaper from CLI?

By Aaron J. Seigo at 09/06/2012 - 06:09

On Wednesday, September 5, 2012 17:50:28 Michael Pyne wrote:
we have code that changes the wallpaper given an arbitrary image URL. it needs
to be put into (or accessed from) an SLC plugin, and that is trivial work.

getting application development to move beyond the concept that "integration
with the desktop means tightly coupling with it" is the less trivial work. :)

Re: How Can I change wallpaper from CLI?

By Christoph Feck at 09/05/2012 - 14:30

On Wednesday 05 September 2012 20:10:53 Alexander Neundorf wrote:
It's still being worked on, see bug 217950 and linked review request.

Re: How Can I change wallpaper from CLI?

By =?utf-8?Q?Thoma... at 09/05/2012 - 14:31

Am 05.09.2012, 20:10 Uhr, schrieb Alexander Neundorf < ... at kde dot org>:

"Good morning" (scnr :-)


Re: How Can I change wallpaper from CLI?

By Alexander Neundorf at 09/05/2012 - 14:52

On Wednesday 05 September 2012, Thomas Lübking wrote:
I actually didn't even switch away from the default wallpaper anymore since
using KDE4, since it is so pretty :-)


Re: How Can I change wallpaper from CLI?

By kevinzhow at 09/05/2012 - 10:58

Because there are also some features need a client to achieve..
You can sync the wallpaper to your cell phone (whatever wp android or iOS) through the client with the phone side client. Something like this.

在 2012-9-5,下午10:53,Tomaz Canabrava < ... at kde dot org> 写道: