Why and how libadwaita prevents theming?

I love Adwaita design, but sometimes in special cases I might use theming. Apparently, it is prevented in Libadwaita, why and how technically? And how some people are still able to theming it?

Can anyone answer?


«Theming» is discouraged because it depends on a misuse of GTK’s styling system to work, and has been done for so long that people don’t remember that it’s an unsupported hack. It’s in Tweaks instead of Settings for a reason. Arbitrarily changing the style of an app to something it wasn’t intended to be used with can easily lead to broken apps, which is why it’s especially problematic that some distros override the style of apps by default.

Some more reading on this:

If you search, you will find ways to override the styling of Adwaita apps, but none of these are officially supported in any way.

1 Like

There is no “theme” in GNOME world; just hacked alternative stylesheets. If you’re looking for customizations, stay tuned with GNOME development. For now, the accents colors are in the way.

1 Like

Yeah, I know about that and I agree, distro themes are definitely sucks, but I also hate artificial restrictions… So, can you tell how libadwaita technically prevent using themes from GTK? How libadwaita prevent changing its own stylesheet file? And what are the different ways go around these restrictions if I want?

And is this design that prevent themes just because? Have this design other benefits? Blocking is just a side effect?

I don’t dispute the problems with replacing stylesheets and I think distros should stop it, but the artificial restrictions are stupid. If I want to break my app, let me please…

If you want to break any old open source app, you can just grab the source code and start editing it. Libadwaita does not actually prevent app themes through any technical means, the app just needs to implement the themes itself (see for example gnome-text-editor).

Why old one?

Hi there, I understand your perspective on this. You and other app devs have received so much “bug reports” about this and OFC it annoys. But I hope you also can get my point that is if user consciously wants modify (and potentially break) his apps and knows the problems, let them do it. Or do you disagree?
Fork, build your self, etc. is a bit bad way to react this.

Could you explain in a bit more detailed? Something clearly makes apps that use libadwaita harder to modify than those that use GTK without it.

Sorry, I should say for new ones, too.

Users can already modify the apps, by forking and building themselves. That is the standard way to modify apps. I am not sure what you mean by libadwaita is harder to modify, it is the same process. A theme is not actually different in that aspect from any other part of the app. Apps could choose to implement “plugins” to let you modify certain parts of the app (many GNOME apps do) but they don’t have to. Similarly, they can implement a theme system to let you modify some of the app’s styles, but they don’t have to. If you want to take an open source app and add a theme system to it then you can also do that, but then you get to be the person who receives all the bug reports.

Edit: Just from my personal experience, nothing actually makes it harder. It is just a perception. Some people seem to have some idea that GNOME apps are supposed to be themed, but this has not been true for quite some time. I have noticed this mostly with the standard GNOME apps. some folks seem to think that because the apps are relatively simple and have standard functionality then it should be easy to theme them. This is not the case. The interaction with the styles and with libadwaita are an essential part of the app itself and they can’t be changed without changing the entire app around. If a developer wanted more theming then the app would have to be designed around that from the beginning and may have to sacrifice functionality for it.

Sorry, but I have to say, do you misunderstood my question intentionally?
I didn’t claim that modifying apps that uses libadwaita is harder that the ones that isn’t use libadwaita. If you have source code of the software OFC you can always modify that software however you want, but I doesn’t ask anything about that. I talk about built software what I as user get from repos of distro (e.g. Ubuntu, Fedora, etc) that I use.

Back to topic:

So the thing is most of apps that use libadwaita are defintely harder theming that the ones that use GTK without it. And questions are:

  1. How libadwaita technically refuses using stylesheets from GTK?
  2. How libadwaita prevent changing its own stylesheet file?
  3. What are the different ways (without need build anything from source) go around these restrictions if I want?
  4. Is this design that prevents theming just because? Have this design other benefits?

Please answer one-by-one

Please do not assume anyone has bad intentions, that is not the way to have a good discussion. Modifying built software is always going to be harder and more limited than modifying source code. It does not matter if it is a theme or some other part of the app. If an app developer does not want some part of an app to be modified at run-time then they will just not build in that functionality. That is simply the way some apps are designed. In any case you will always have much more flexibility by modifying the source code.

But to answer your questions:

  1. It doesn’t. An app can load whatever stylesheet it wants into GTK.
  2. It doesn’t. An app can override any libadwaita styles.
  3. There are infinite ways to answer this. It depends completely on what the app wants to do, see the previous two answers. If the app developer really does not want you doing it then there is nothing you can do aside from modifying the source code (or the binary itself if you know how). Because again, an app needs to be explicitly designed to be able to do what you are asking.
  4. No.

I’m sorry.

Of course, but anyway back in the GNOME 3 days I could theming all GTK apps.

So in GNOME 3 days devs also could have also block theming easy? And libadwaita doesn’t change anything? alatieras’s blog says of libadwaita following "Yes, applications, as is, will not be following a custom system theme. "…

Yeah, they maybe can, but why doesn’t do it? Same apps that formely in the GNOME 3 days did it.

Your misunderstood my question. Why I can’t change stylesheet files of libadwaita? I mean if app get styles from libadwaita and if I modify libadwaita to give custom styles.

I mean commonly. Of course I can even make app that writes directly to Wayland window without any toolkit library, but…

No for “Is this design that prevents theming just because?” or “Have this design other benefits?”?

That was not my experience with GTK3 apps. Frequently I saw people trying to theme some app and it just broke or the theme did not work at all. The system theme in GTK3 was never intended to be set by the user or the distro either, that was always a setting the app was supposed to use. The only thing that has changed in libadwaita is now libadwaita sets it automatically instead of requiring the app to set it manually.

You can, just modify the styles and recompile libadwaita. But there is no reason to actually do this, it is very likely it will break all your apps. Because again, using libadwaita means the libadwaita styles are a critical API dependency of the app. For the same reason you cannot just go into libadwaita and change random API functions to take ints instead of strings or something like that, it would break everything. This is not some kind of design, this is just how every API works.

If you want to fully implement any style you want in any way you want, then yes I would suggest you do that. But app developers using libadwaita means they want the libadwaita styles, not just random broken styles.

There is no specific design. If there was, it would not prevent theming “just because.” Whatever other benefits are up to the app developer on what they want to design.

As I said, I don’t doubt that. Theming is broken consept, but that doesn’t change the fact that in the GTK 3 days if it set theme every basically GTK apps followed that, right? Same case is in GTK 4 apps if they doesn’t use libadwaita. Libadwaita is only one that is changed and it some how prevents theming and I interested in how it does that?

Can you clarify this?

So is the case this?
GTK by default uses hardcoded theme called Default.
If $GTK_THEME is set GTK will use stylesheet from path in that variable.
Libadwaita by default set $GTK_THEME to point libadwaita itself and that theme is hardcoded

So:
If app uses just GTK by default stylesheet will be hardcoded GTK Default or $GTK_THEME
App can block this only if it set $GTK_THEME to point the app itself and its hardcoded theme

If app uses GTK and libawaita by default stylesheet will be hardcoded libadwaita
App can somehow ask libadwaita not to set $GTK_THEME

How then couls GTK allow set custom stylesheets?

If you didn’t mean either, I can’t understand what did you mean by “No.”? Please read the thread from the beginning.

If the themes were just broken and did not work, then I would not say they followed that. I would say that is not a working theming. Again, libadwaita does not prevent theming, the situation is mostly the same as it was in GTK3 if your GTK3 app required the adwaita theme.

Clarify what? Please ask a more specific question.

Not quite. Libadwaita actually contains multiple themes (light, dark, high contrast, high contrast dark) and it switches between them depending on how the user has configured the system.

Any app can just unset any environment variable. That variable is meant for testing, not for theming.

It already does, see here: Gtk.CssProvider.load_from_file

But this function has to be called by the app because the behavior of a stylesheet completely depends on how the app is constructed.

I did. Please do not put two questions on the same line if you want a simpler answer to a single question. Your list had 4 lines but actually there are 5 questions and the last 2 are not really related. Otherwise it is difficult for me to give you clear answers.

But if app just unset $GTK_THEME stylesheet will be GTK Default?

That variable is meant for testing, not for theming.

So how GTK, Libadwaita, etc technically sets stylesheets?

No, I tried ask, why GTK allow custom stylesheets but libadwaita not? GTK is also critical, right?

It will be whatever the app sets the gtk-theme-name GtkSetting to. Libadwaita will just set this for the app automatically (technically right now it sets it to an empty theme to make the adwaita themes work correctly in all cases)

See the function I just linked, that is essentially what libadwaita uses. Apps can also use it to set their own styles but those are also dependent on the app.

They both do. Apps use the same function to apply custom stylesheets in either case.

I think what you are missing is that in CSS there can be multiple stylesheets and they are all combined together to form the total style of the app.

Since I’m novice, would you explain whole case from GTK to libadwaita and app with links to the source? :sweat_smile: Apparently $GTK_THEME has nothing to do with this and just overwrites everything?

That comment was reply to this “But there is no reason to actually do this, it is very likely it will break all your apps. Because again, using libadwaita means the libadwaita styles are a critical API dependency of the app. For the same reason you cannot just go into libadwaita and change random API functions to take ints instead of strings or something like that, it would break everything. This is not some kind of design, this is just how every API works.”.. If I build GTK and replace GTK Default that isn’t so big mess that building and replacing libadwaita’s default theme, why?

No, I can’t right now, sorry. That would be a long article to write. If you want to look in source code yourself, you can search GTK, libadwaita, etc for usages of GtkCssProvider, that is the main entry point for style sheets. Just pick an app you are interested in and start there.

GTK_THEME may overwrite everything and break every app or it may not. It is impossible to tell without reading the source code to every app you use it for, and understanding how the app’s stylesheets work. Because essentially you are just changing random styles out from underneath the app. That is why I say it is only for testing.

That would also break apps in exactly the same way, if they required the default GTK theme.

I just want know path that decide used stylesheets and the way that sets them (since apparently it isn’t environment variable). GTK Default (hardcoded in GTK binary) → custom → default of libadwaita (hardcoded) → apps stylesheets and if $GTK_THEME enabled only that stylesheets will be used?

But for years we are changed that altought?