Bug 430046 - Cannot set dark theme for gtk2 apps
Summary: Cannot set dark theme for gtk2 apps
Status: CLOSED INTENTIONAL
Alias: None
Product: systemsettings
Classification: Applications
Component: kcm_style (show other bugs)
Version: 5.20.4
Platform: Other Linux
: NOR normal
Target Milestone: ---
Assignee: Plasma Bugs List
URL:
Keywords:
: 433080 (view as bug list)
Depends on:
Blocks:
 
Reported: 2020-12-05 15:34 UTC by medin
Modified: 2022-07-30 13:59 UTC (History)
4 users (show)

See Also:
Latest Commit:
Version Fixed In:
Sentry Crash Report:


Attachments
Cannot set dark theme for gtk2 apps (139.06 KB, image/png)
2020-12-05 15:34 UTC, medin
Details

Note You need to log in before you can comment on or make changes to this bug.
Description medin 2020-12-05 15:34:45 UTC
Created attachment 133892 [details]
Cannot set dark theme for gtk2 apps

After latest update to 5.20.4 I cannot set gtk2 apps to use dark themes like dark breeze, only gtk3 apps can be themed. See attached image for more info.

Operating System: Manjaro Linux
KDE Plasma Version: 5.20.4
KDE Frameworks Version: 5.76.0
Qt Version: 5.15.2
Kernel Version: 5.4.80-2-MANJARO
OS Type: 64-bit
Comment 1 medin 2020-12-06 12:36:39 UTC
The problem is that after choosing "Breeze Dark" as global theme and dark color scheme "Breeze Dark" in settings, for GTK3 there is a parameter called "gtk-application-prefer-dark-theme" that's set to "true" to apply dark color scheme, but for GTK2 there is no parameter and we have only gtk-theme-name set to "Breeze", to solve the problem Plasma settings should set gtk-theme-name for GTK2 to "Breeze-Dark" when dark color scheme "Breeze Dark" is selected.
Comment 2 Nate Graham 2020-12-07 17:34:23 UTC
Yea I'm afraid this feature was removed in Plasma 5.20 as it was impossible to make it work correctly due to unfixable deficiencies in GTK2. Any app still using GTK2 at this point ought to be ashamed of itself; GTK2 has been unmaintained for years and GTK4 is about to be released. Go bug the developers to be responsible and port their apps to a more modern toolkit. :)
Comment 3 medin 2020-12-07 18:51:35 UTC
(In reply to Nate Graham from comment #2)
> Yea I'm afraid this feature was removed in Plasma 5.20 as it was impossible
> to make it work correctly due to unfixable deficiencies in GTK2. Any app
> still using GTK2 at this point ought to be ashamed of itself; GTK2 has been
> unmaintained for years and GTK4 is about to be released. Go bug the
> developers to be responsible and port their apps to a more modern toolkit. :)

But it was working fine before 5.20, and many useful GTK2 apps are still useful and have no GTK3 or Qt alternative and will never ported to new GTK3+ versions, so demanding many old apps (whose some maintainers are already dead) to be upgraded to match plasma logic seems to be far away from reasonable. I use some old GTK2 apps that weren't maintained for many years and they still work fine and do the work perfectly.

At least in 5.19 there was options for GTK2 and GTK3 themes, if GTK2 has some problems why not let the option for the user to choose GTK2 theme manually instead of removing it and break theme selection for all those old useful apps ?

Some platform (like JDK and Python) are still supporting GUI apps that were written for more than 20 years and they still work fine, so why Plasma choose to remove existing working solution and break other apps ?
Comment 4 Nate Graham 2020-12-07 19:02:06 UTC
It was *not* working fine in 5.20.

It may have been working fine for your particular use case due to a random confluence of factors. But it was broken for many people, and it was broken in a way that made various apps unusable. For example in certain apps, text was sometimes the same color as the background, making it unreadable.

We tried various methods of fixing these sorts of issues while preserving the color-changing feature, but in the end we were unable to. We removed the feature to prevent people from being able to make some of their apps literally unusable.

Again, the real solution is for those apps to get ported to GTK3. GTK2 is a dead toolkit. If these apps cannot be ported because they are abandoned, that's all the more reason we shouldn't be monkeying with their appearance; we may break them. And in fact we did. Old unmaintained apps using old unmaintained toolkits are fragile. The more time goes on, the less well they work as the world changes around them but they don't adapt. The best way to keep them usable is to change that world around them as little as possible. This means not trying to dynamically change their colors.

I know that's not what you wanted to hear, sorry. :)
Comment 5 medin 2020-12-07 19:19:52 UTC
(In reply to Nate Graham from comment #4)
> It was *not* working fine in 5.20.
> 
> It may have been working fine for your particular use case due to a random
> confluence of factors. But it was broken for many people, and it was broken
> in a way that made various apps unusable. For example in certain apps, text
> was sometimes the same color as the background, making it unreadable.
> 
> We tried various methods of fixing these sorts of issues while preserving
> the color-changing feature, but in the end we were unable to. We removed the
> feature to prevent people from being able to make some of their apps
> literally unusable.
> 
> Again, the real solution is for those apps to get ported to GTK3. GTK2 is a
> dead toolkit. If these apps cannot be ported because they are abandoned,
> that's all the more reason we shouldn't be monkeying with their appearance;
> we may break them. And in fact we did. Old unmaintained apps using old
> unmaintained toolkits are fragile. The more time goes on, the less well they
> work as the world changes around them but they don't adapt. The best way to
> keep them usable is to change that world around them as little as possible.
> This means not trying to dynamically change their colors.
> 
> I know that's not what you wanted to hear, sorry. :)

I have Ubuntu MATE and GTK2 apps with many themes are still working fine, so it's just some limitation that Plasma encountered  (or created by itself) while trying to unify the theme mechanism for GTK3 and Qt while breaking old apps (and probably will repeat when GTK version increases again in future).
I found that it's enough to set the full theme name in gtk-theme-name inside .gtkrc-2.0 file. But Plasma settings breaks manual modification, for example if I set gtk-theme-name to Breeze-Dark in .gtkrc-2.0 file and change global theme in settings to Breeze Dark then gtk-theme-name will be reset to Breeze which breaks the manual modification and force light theme for GTK2 while It uses dark theme for GTK3 and Qt apps.
So if GTK2 support is removed why it is still trying to interfere and reset manual changes ?
Comment 6 Mikhail Zolotukhin 2020-12-07 19:24:35 UTC
Probably going to make my life harder, but I think there is some truth in "This was working fine". The thing is now we set Breeze theme for all GTK3 and GTK2 apps. Previously there was an opportunity to set Breeze-Dark for GTK3 and GTK2. It didn't change a thing for GTK3 apps, since its colors was brought from system Color Scheme (and this was misleading, that's why I removed that ability), but GTK2 apps used a dark Breeze variant.

After the removal it's no longer possible to set Dark Breeze theme for GTK2 and GTK3 apps and that's why while GTK3 apps are working fine, GTK2 ones are broken.

I think there is a hacky way to make GTK2 apps at least respect "Dark Mode" - it is to use Breeze-Dark setting variant under the hood, while setting Breeze theme or setting color scheme.

For example: if the user sets the GTK theme to Breeze - check if the current color scheme is dark (we already can do that) and if it is, set the theme to the "Breeze-Dark", if it is not, set to just "Breeze". The similar approach can be used with the color scheme change.
Comment 7 Mikhail Zolotukhin 2020-12-07 19:28:47 UTC
> So if GTK2 support is removed why it is still trying to interfere and reset
> manual changes ?

GTK2 support was not removed. We just removed the ghostly possibility to change the GTK2 theme to a different one from GTK3, because it is impossible to do so due to technical reasons anyway.
Comment 8 medin 2020-12-07 19:34:32 UTC
(In reply to Mikhail Zolotukhin from comment #6)

> I think there is a hacky way to make GTK2 apps at least respect "Dark Mode"
> - it is to use Breeze-Dark setting variant under the hood, while setting
> Breeze theme or setting color scheme.

Yeah this is what drives me crazy, I set Breeze-Dark in .gtkrc-2.0 but Plasma settings resets it to Breeze after I change global theme to Breeze Dark.
Comment 9 Mikhail Zolotukhin 2020-12-10 19:58:44 UTC
I tried to do what I was talking about and it seems like this workaround requires modification of the code in too many places with ambiguous unforeseen consequences. Doing so just to implement "Dark Mode" for GTK2 apps seems unreasonable to me. As I have discovered, this approach is VERY bug prone and, due to my limited time, I'm not sure I'm ready for potential bugs, that will be discovered in case of that change (I need to fix them you know, otherwise it's just irresponsible). I suggest learning the lesson Half-Life taught us and not touch what can cause the breakage in the working system. Sorry to inform about that.

> Yeah this is what drives me crazy, I set Breeze-Dark in .gtkrc-2.0 but
> Plasma settings resets it to Breeze after I change global theme to Breeze
> Dark.

You can completely disable GTK sync module in Background services KCM. Still, modifying .gtkrc won't help you, unless you manually stop the xsettigsd. (You can manually edit its config in ~/.config/xsettingsd/xsettingsd.conf).
Comment 10 Nate Graham 2021-02-18 17:12:11 UTC
So for some context, this change to not even try to theme GTK2 apps was made in https://invent.kde.org/plasma/plasma-desktop/commit/2fb0bf85fe63fa7ba7fc0af4e0bf7db6da8d5d40, to fix bugs like Bug 412331.
Comment 11 Nate Graham 2021-02-18 17:12:23 UTC
*** Bug 433080 has been marked as a duplicate of this bug. ***
Comment 12 Peter Power 2022-07-30 13:59:12 UTC
I struggle with this issue as well. I wanted to use the dark colors for the gtk2 app. 

As explained the feature has been removed to move forward and the colors / variations feature can't be handled anymore by kde for GT2 themes, resulting in the bright / light version being used as the default.

I'm happy to still be the unique owner of my machine so I just did a 
sudo cp -rf /usr/share/themes/Breeze-Dark/gtk-2.0/* /usr/share/themes/Breeze/gtk-2.0/
to overwrite the default gtk2 light color for the default Breeze by the dark one. Et voilà !

Claws Mail with the dark colors and backgrounds showing up under KDE !  
No offence gentlemen, I'm still using claws under KDE for my primay email software :-P

Of course you shouldn't do that. Nobody would ever recommend to perform an action like that.
It's working but depending on the distro you are screwing something as a side effet
 (lost in system upgrades, default settings for gtk2 messed up, etc... ) 

Don't worry.... Be Happy ! Cheers and hope it will help others who love dark themes.

Best Regards

Operating System: OpenMandriva Lx 4.3
KDE Plasma Version: 5.23.5
KDE Frameworks Version: 5.90.0
Qt Version: 5.15.3
Kernel Version: 5.16.13-desktop-1omv4003 (64-bit)