mirror of
https://github.com/AvengeMedia/DankMaterialShell.git
synced 2026-08-01 19:18:28 -04:00
feat(Themes): add support for GTK3 dynamic theming (#2523)
* 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
This commit is contained in:
@@ -386,8 +386,8 @@ func buildOnce(opts *Options) (bool, error) {
|
||||
default:
|
||||
syncAccentColor(primaryDark)
|
||||
}
|
||||
refreshGTK(opts.Mode)
|
||||
refreshGTK4()
|
||||
refreshGTKTheme(opts.Mode)
|
||||
refreshGTKColorScheme()
|
||||
}
|
||||
|
||||
if isDMSKDEColorSchemeActive(opts.ConfigDir) {
|
||||
@@ -911,7 +911,7 @@ func generateDank16Variants(primaryDark, primaryLight, surface string, mode Colo
|
||||
}
|
||||
|
||||
func isDMSGTKActive(configDir string) bool {
|
||||
gtkCSS := filepath.Join(configDir, "gtk-3.0", "gtk.css")
|
||||
gtkCSS := filepath.Join(configDir, "gtk-4.0", "gtk.css")
|
||||
|
||||
info, err := os.Lstat(gtkCSS)
|
||||
if err != nil {
|
||||
@@ -968,7 +968,7 @@ func applyKDEColorScheme(mode ColorMode) {
|
||||
}
|
||||
}
|
||||
|
||||
func refreshGTK(mode ColorMode) {
|
||||
func refreshGTKTheme(mode ColorMode) {
|
||||
if err := utils.GsettingsSet("org.gnome.desktop.interface", "gtk-theme", ""); err != nil {
|
||||
log.Warnf("Failed to reset gtk-theme: %v", err)
|
||||
}
|
||||
@@ -993,8 +993,8 @@ func expectColorSchemeEcho(scheme string) {
|
||||
// apps reload ~/.config/gtk-4.0 CSS (a gtk-theme flip does not). But apps
|
||||
// following the portal color-scheme (Chromium) can drop the restore signal
|
||||
// mid-repaint and latch the wrong mode, so this is opt-in.
|
||||
func refreshGTK4() {
|
||||
if os.Getenv("DMS_ENABLE_GTK4_REFRESH") != "1" {
|
||||
func refreshGTKColorScheme() {
|
||||
if os.Getenv("DMS_ENABLE_GTK_REFRESH") != "1" {
|
||||
return
|
||||
}
|
||||
output, err := utils.GsettingsGet("org.gnome.desktop.interface", "color-scheme")
|
||||
@@ -1012,13 +1012,13 @@ func refreshGTK4() {
|
||||
|
||||
expectColorSchemeEcho(toggle)
|
||||
if err := utils.GsettingsSet("org.gnome.desktop.interface", "color-scheme", toggle); err != nil {
|
||||
log.Warnf("Failed to toggle color-scheme for GTK4 refresh: %v", err)
|
||||
log.Warnf("Failed to toggle color-scheme for GTK refresh: %v", err)
|
||||
return
|
||||
}
|
||||
time.Sleep(400 * time.Millisecond)
|
||||
time.Sleep(50 * time.Millisecond)
|
||||
expectColorSchemeEcho(current)
|
||||
if err := utils.GsettingsSet("org.gnome.desktop.interface", "color-scheme", current); err != nil {
|
||||
log.Warnf("Failed to restore color-scheme for GTK4 refresh: %v", err)
|
||||
log.Warnf("Failed to restore color-scheme for GTK refresh: %v", err)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user