Javascript to change the default wallpaper in plasma

Raphael Hertzog hertzog at debian.org
Tue Aug 16 09:57:32 UTC 2016


Hello Bushan and Marco,

thanks for your answers!

Le jeudi 28 juillet 2016, Bhushan Shah a écrit :
> > I tried to look out for documentation but the only thing that I did
> > find is this wiki page and it doesn't seem to be entirely up-to-date:
> > https://userbase.kde.org/KDE_System_Administration/PlasmaDesktopScripting
> 
> For Plasma 5, scripting have some bits changed, see following wiki
> https://userbase.kde.org/KDE_System_Administration/PlasmaTwoDesktopScripting

Thanks, it helped me to get in the right direction. But the instructions
on that page do not seem 100% accurate either. And the introductory text
does not make it very clear to which version each page applies.

In particular:
> > For instance, I was not able to run the interactive scripting dialog
> > with "qdbus org.kde.plasma-desktop /MainApplication
> > showInteractiveConsole"
> 
> With Plasma 5, you can start kwin console with following
> qdbus org.kde.plasmashell /PlasmaShell org.kde.PlasmaShell.showInteractiveConsole

You should update this in the above wiki page.

Le jeudi 28 juillet 2016, Marco Martin a écrit :
> On Mon, Jul 25, 2016 at 9:01 PM, Raphael Hertzog <hertzog at debian.org> wrote:
> >     d = desktops()
> >
> >     for (i in d) {
> >         d[i].wallpaperPlugin = 'org.kde.image'
> >         d[i].currentConfigGroup = Array('Wallpaper', 'org.kde.image', 'General')
> >         d[i].writeConfig('Image',
> >                 'file:///usr/share/images/desktop-base/desktop-background')
> >         d[i].writeConfig('FillMode', '2')          //enables croping
> >     }
> >
> > But it doesn't seem to work and I don't know why. It's possible that the script
> > is not executed at all...
> 
> the script is correct.
> you have to make sure the file actually exists looks suspicious that
> does't have an extension, for instance on the local installation here
> i have
> /opt/kde5qt5/share/wallpapers/ColorfulCups/contents/images/1920x1080.jpg

The image file exists and it is a (configurable) symlink and that's why
it doesn't have any extension.

It looks like the main problem that I had left was figuring out a place
where I could put the files so that it gets executed on initial setup.
It looks like plasma no longer supports multiple files and instead
you should provide a "layout.js"... since I did not want to override
the file provided by the official Debian package, I opted to use
one "updates" script since they are also executed at initial setup.

Apparently the correct directory (at least on Debian) is
/usr/share/plasma/shells/org.kde.plasma.desktop/contents/updates/

When put there, I get the desired effect. The unfortunate side-effect
is that this will reset the background of people who upgrade the
desktop-base package (which ships the new javascript file) and
are not in their initial setup.

It would be nice if the default layout.js had some hook to call other
javascript files in a predefined path so that we could fix this properly.

Cheers,
-- 
Raphaël Hertzog ◈ Writer/Consultant ◈ Debian Developer

Discover the Debian Administrator's Handbook:
→ http://debian-handbook.info/get/


More information about the Plasma-devel mailing list