Repository navigation
feat(Themes): add support for GTK3 dynamic theming - #2523
Conversation
This will be great.
This would probably also solve #1555 as a side effect.
Sounds acceptable to me. The current way of simply overwriting everything with the adw3 light theme is certainly not better.
If DMS is committed to adw-gtk3 anyway, it can also ship it. And if a prefix is added, this really keeps it separate from the system installation. |
This comment was marked as spam.
This comment was marked as spam.
17ce844 to
d9e8cc8
Compare
|
Following 8f10096 :
If iterating over the adw-gtk3 installation directory candidates in order of preference is enough, then I gladly embrace the minimalism of the solution, and there is - I think - no need for any discussion at all. N.B. : this also reverts part of 8f10096 (since adw-gtk3 assets healing is no longer needed) Footnotes
|
56fed1b to
8bf2ad1
Compare
|
So, I spoke too soon and way too early in the morning and things were not exactly correct to say the least. |
bb053fb to
f775ebe
Compare
|
@euletheia Is this ready for testing from your side? |
f1eb709 to
99d7f5f
Compare
|
Added the missing update of GTK theme on dms theme change by re-implementing @real-or-random Everything is even more ready and should be working as expected (don't forget to compile dms so that Sorry for the repeated updates. |
|
Okay, I installed this locally. A few observations. When I started DMS for the first time, I didn't have a local copy of the theme. DMS greeted me with "failed to apply GTK colors" (or similar). Switching light/dark themes still works, but the colors are wrong. (I think that's exactly what we expect in the case of this error message). After that first failure, clicking "Apply GTK colors" in Settings results in a confirmation "GTK colors applied succesfully". But the I copied the theme: Then the script works, and the colors will be applied even in running apps. At least in light mode. Dark mode colors seem to be the adw-gtk3-dark default, and setting different colors in the DMS settings has no effect on dark mode colors in gtk3 apps. And changing colors in running apps is not perfect (both after setting a different color of after toggling light/dark). For some UI elements, a redrawing needs to be forced manulaly For example, the background color of the active search bar in Evolution doesn't change when toggling dark/light mode. Only after starting a new search, it is redrawn and the new color applies. Not sure if anything can be done here or if this is even a bug in Evolution. Does the initial error message at DMS startup also come from a run of the script? I haven't looked at the code, but shouldn't the script only run when clicking the button? If the error message is a result of script, then Why did the inital run of the script have a bad exit status? I don't know. Maybe ran before matugen and hit this error path? Summary / conclusions:
One more thought on the approach in general? Do you have an idea why overriding colors like this works while writing to |
473eea6 to
f19ad82
Compare
|
Sorry, too many moving parts. @bbedward When I download the script and run @euletheia Am I supposed to have a local copy of |
|
Your branch might need rebased? There was a fix for that one of the last couple days. Easier way to test though is to just run |
Both are needed. |
There was a problem hiding this comment.
Great, this now works nicely for me. 👍
- The embedded script now runs properly.
- The colors are now applied correctly in dark mode.
- The only thing that I can still observe is the that some rare UI elements (e.g. background color of search box in Evolution) are not updated on a color change, and need a "manual" refresh by interacting with the UI. But this is super minor and I tend to believe it's a bug in gtk3 or in Evolution.
As for further steps, which could happen in a separate PR (this is a maintainer call obviously), I still believe that vendoring the themes would be the cleanest thing to do. Or alternatively, we'll need proper docs that tell the user to have local copies of adw3-gtk and adw3-gtk-dark. If we decide to vendor, then I believe it will be fine to get rid of the fallback override entirely.
|
Depending on what seems right to the maintainers, I'd be happy to submit a PR for either the docs or the themes vendoring. |
| CONFIG_DIR="$1" | ||
| SHELL_DIR="$3" | ||
| # apply: setup symlinks and config dirs | ||
| # refresh: refresh overrides in adw-gtk3 |
There was a problem hiding this comment.
It still doesn't match, I think you want this:
| # refresh: refresh overrides in adw-gtk3 | |
| # include: refresh overrides in adw-gtk3 |
There was a problem hiding this comment.
Yes thank you : seems like I wasn't quite settled on which term to use :)
EDIT: That might be splitting hairs, but I included an additional commit to make the actual behavior clearer.
There was a problem hiding this comment.
No I agree, "patch" is much better than "include". :)
Instead of overriding named colors of all GTK3 themes via the config directory file, only override named colors for each variant of the adw-gtk3 theme (light and dark), and let GTK3 apps change themes depending on the value of org.gnome.desktop.interface color-scheme.
- remove gtk3 override if it's a symlink - remove call to gtk.sh with old arg 'assets-only' - append key to dconf path to respect dconf write signature
- rename DMS_ENABLE_GTK4_REFRESH to DMS_ENABLE_GTK_REFRESH - revert a3fba8
Allow to remove all inclusions and overrides for GTK.
real-or-random
left a comment
There was a problem hiding this comment.
I haven't retested this, but the diff from the tested 450a535 looks fine to me. Good to go from my side.
@bbedward What do you think should be the next step? And big thanks to @euletheia for this PR and for volunteering to work on the next one. |
Friendly ping. @bbedward The main task is done but it will be hard for users to make use of without either vendoring gadw3-gtk(-dark) or updating the docs. |
|
@real-or-random Vendoring adw-gtk3 is not exactly prohibited but a little shaky since its LGPL licensed and we're modifying it via matugen. I think I'll go with documenting the install + copying the theme from system to ~/.local/share/themes ourselves in the gtk script |
ref #2523 i with '#' will be ignored, and an empty message aborts the commit.
* feat(Themes): add support for GTK3 dynamic theming Instead of overriding named colors of all GTK3 themes via the config directory file, only override named colors for each variant of the adw-gtk3 theme (light and dark), and let GTK3 apps change themes depending on the value of org.gnome.desktop.interface color-scheme. * fix(Themes): apply requested changes - remove gtk3 override if it's a symlink - remove call to gtk.sh with old arg 'assets-only' - append key to dconf path to respect dconf write signature * refactor(Themes): separate 'include'/'apply' logic for GTK3 dynamic theming * revert(Themes): reset timer between color-scheme refresh - rename DMS_ENABLE_GTK4_REFRESH to DMS_ENABLE_GTK_REFRESH - revert a3fba8 * feat(Themes): add 'remove' mode to gtk.sh Allow to remove all inclusions and overrides for GTK. * fix(Themes): backup adw-gtk3 original css in 'apply' (not 'include') * style(Themes): rename argument 'include' to 'patch' for clarity
'Proof of concept'
Instead of overriding named colors of all GTK3 themes via the config directory file, override only named colors for each variant of the adw-gtk3 theme (light and dark), and let GTK3 apps switch theme variant depending on the value of org.gnome.desktop.interface color-scheme.
This implies :
gtk-light-colors.cssmatugen template1.However, the main shortcoming of this method is having to rely on the adw-gtk3 theme being installed in the user themes directory2 when package managers will install it system-wide in
/usr/share.This also entails that theming GTK3 apps without adw-gtk3 (via the
.configoverride) would no longer be provided by DMS (at least I did not write anything to provide a fallback/choice).Eventually, I don't know on which side you think the burden should weigh, but a stable solution could be to vendor the theme3.
Obviously, considering the size of the change, I could have overlooked some issues, but I've been using this patch for roughly a week and it seems stable.
Screenshots
contrib_DMS.mp4
Footnotes
At least my tests showed no blatant issue without those 8000 LOC. ↩
Considering they don't use the legacy
$HOME/.themesfolder. ↩with a "dank" prefix to differentiate it from the original ? ↩