I have tried reading config files but there must be a more standard way.
Any thoughts ?
You mean from a bash script or something? What’s your ultimate end goal?
Part of the challenge is that there is no “current desktop wallpaper” each Screen and Activity can have its own wallpaper.
Oh sorry the question was not clear enough.
I am trying to get the wallpaper of the current desktop via c++ code (Using Qt).
KConfig config3("plasma-org.kde.plasma.desktop-appletsrc", KConfig::NoGlobals);
const auto groupList = config3.groupList();
KConfigGroup generalGroup(&config3, "Containments");
for (const QString& group : generalGroup.groupList()) {
KConfigGroup subGroupContainments(&generalGroup, group);
if( subGroupContainments.groupList().contains("Wallpaper")){
KConfigGroup wallpaperSubGroup(&subGroupContainments, "Wallpaper");
KConfigGroup orgSubGroup(&wallpaperSubGroup, "org.kde.image");
KConfigGroup generalGroup(&orgSubGroup, "General");
QString imagePath = generalGroup.readEntry("Image");
if(imagePath.endsWith('/')){
//its a folder.
QDir directory(imagePath+"contents/images/");
QStringList images = directory.entryList(QStringList() << "*.png" << "*.PNG",QDir::Files);
qDebug()<<images[0];
}
}
}
For now this is my solution, tho I think there should be an API for that to get it in a safer way.
Right, but for what purpose? What’s your end goal?
I think he is just asking if there are any plasma API which returns the current wallpaper. Probably to use in a app I guess…
1 Like
I want to use the wallpaper in my app, just for training with Qt and Kirigami.