Reply to topic

How does Plasma change theme under the hood?

Registered Member
I wonder how Plasma changes theme under the hood.

I see lookandfeeltool which changes theme "lookandfeeltool -a <themename>" yet I do not know how it does that. Oddly, I cannot seem to find the source code for it. It is probably inside somewhere of "plasma-desktop" repo.

One thing came to my mind was to check if it uses DBus. I did:

Code: Select all
strings "$(which lookandfeeltool)" | grep "org.kde"

which printed

Code: Select all

org.kde.lookandfeeltool and org.kde.kdecorations2 are not in session bus. org.kde.KLauncher is there but it does not have a method to change the theme.

So, I have multiple questions:

  • How can I change Plasma color schema, widget style etc. programmatically?
  • How can I get a list of color schemas, widgets programmatically? Where are these stored in the filesystem?

KDE is great and all but when it comes to program it yourself, it seriously lacks documentation.

Thanks in advance.
User avatar Mamarok
viewtopic.php?f=305&t=165711 might also be of help

Currently running Kubuntu 20.04, Plasma 5.18.5, Frameworks 5.68.0, Qt 5.12.8, kernel 5.4.0-34
FWIW: it is always useful to state the Plasma version and distribution when asking questions in this forum, makes it easier for us to help ...
Registered Member
First, theming of Plasma isn't unified; it is splitted over several different theming elements, which are all handled differently. For an overview of theming elements, see my comment at ... beginners/

If you are writing a KDE or Qt application, changes in theming (fonts, color scheme, widget style) are usually handled automatically via global Qt events (QEvent::ApplicationFontChange, QEvent::ApplicationPaletteChanged, QEvent::StyleChanged), so there is no pressure to document the process further.

Internally, these events are sent by Qt when Plasma's Qt platform integration plugin changes settings in each application. This plugin listens to D-Bus signals sent by the KCMs. The source is the documentation in this case; see ... ttings.cpp and ... gsdata.cpp

List of available fonts is handled by fontconfig library; available color schemes are in (/usr|~/.local)/share/color-schemes; available widget styles are handled internally by Qt reading the plugin folders, see ... _location/
See also QStyleFactory::keys() documentation.

For theming elements that don't affect applications, but are private to Plasma (e.g. window decorations are handled by kwin, Desktop themes are handled by plasmashell) you would need to find the internals in the source of the relevant KCM pages.

For example, the desktoptheme KCM finds the list of available plasma themes in (/usr|~/.local)/share/plasma/desktoptheme, and notifies plasmashell via changes to its plasmarc config file, see ... smodel.cpp

If your application cannot use KConfig, because it doesn't use KDE's frameworks, you can use the kwriteconfig5 command, e.g.
Code: Select all
kwriteconfig5 --file plasmarc --group Theme --key name breeze-dark

Reply to topic


Who is online

Registered users: annyone, Baidu [Spider], Bing [Bot], claydoh, cmb, denispyr, Don B. Cilly, farid, Google [Bot], Ico_dY, ipwizard, Majestic-12 [Bot], ostroffjh, Section_8, shurato, Sogou [Bot], Steve R.