How Can I change wallpaper from CLI?

Duncan 1i5t5.duncan at cox.net
Thu Sep 6 10:46:35 BST 2012


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

> hello~
> 
> 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
> (http://lovebizhi.com/linux)
> 
> but when i tried  to support KDE I cannot find a possible way to change
> the wallpaper in CLI such like ( kde-wallpaper set file://xxxxx )
> 
> Please give me some tips about this
> 
> Thank you

[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 
wanted.

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.

-- 
Duncan - List replies preferred.   No HTML msgs.
"Every nonfree program has a lord, a master --
and if you use the program, he is your master."  Richard Stallman

___________________________________________________
This message is from the kde mailing list.
Account management:  https://mail.kde.org/mailman/listinfo/kde.
Archives: http://lists.kde.org/.
More info: http://www.kde.org/faq.html.


More information about the kde mailing list