From 09386b1903f197247d5ade3701ae6691eb247f63 Mon Sep 17 00:00:00 2001 From: Lysec Date: Tue, 31 Mar 2026 03:09:55 +0200 Subject: [PATCH] fix(theming): sync gtk-theme with color-scheme when system sync is on --- Scripts/python/src/theming/gtk-refresh.py | 11 ++++++----- Services/Theming/ColorSchemeService.qml | 8 ++++---- 2 files changed, 10 insertions(+), 9 deletions(-) diff --git a/Scripts/python/src/theming/gtk-refresh.py b/Scripts/python/src/theming/gtk-refresh.py index 5a4b080e3..40b67e29d 100644 --- a/Scripts/python/src/theming/gtk-refresh.py +++ b/Scripts/python/src/theming/gtk-refresh.py @@ -99,8 +99,9 @@ async def apply_gtk4_colors(config_dir: Path): async def sync_system_appearance(mode: str, *, update_gtk_theme: bool = True) -> None: """ Push light/dark to org.gnome.desktop.interface (gsettings or dconf fallback). - Used by the GTK template post-hook (also sets gtk-theme when update_gtk_theme) - and by Noctalia on dark-mode toggle (--appearance-only: color-scheme only). + Used by the GTK template post-hook and ColorSchemeService when "Sync system theme" + is on (both set color-scheme and gtk-theme when themes exist). --appearance-only + skips CSS and only updates color-scheme for narrow tooling use. """ has_gsettings = shutil.which("gsettings") has_dconf = shutil.which("dconf") @@ -177,9 +178,9 @@ async def main(): await sync_system_appearance(mode, update_gtk_theme=True) print("GTK colors applied successfully") else: - # Still push light/dark preference so portal/GTK apps follow the shell even when - # gtk.css / noctalia.css setup failed. - await sync_system_appearance(mode, update_gtk_theme=False) + # CSS setup failed; still align gsettings (color-scheme + gtk-theme when themes exist) + # so apps do not end up with mismatched prefer-dark vs adw-gtk3 (inverted look). + await sync_system_appearance(mode, update_gtk_theme=True) sys.exit(1) diff --git a/Services/Theming/ColorSchemeService.qml b/Services/Theming/ColorSchemeService.qml index 8120ac3de..0ef47e21c 100644 --- a/Services/Theming/ColorSchemeService.qml +++ b/Services/Theming/ColorSchemeService.qml @@ -18,14 +18,14 @@ Singleton { property string colorsJsonFilePath: Settings.configDir + "colors.json" readonly property string gtkRefreshScript: Quickshell.shellDir + "/Scripts/python/src/theming/gtk-refresh.py" - // Push org.gnome.desktop.interface color-scheme whenever sync is on (including on every - // darkMode change). GTK template post-hook still updates gtk-theme and CSS; this path only - // sets prefer-light/prefer-dark so apps like Firefox stay in sync even if CSS steps fail. + // When sync is on, run the same gtk-refresh as the GTK template post-hook: set both + // color-scheme and gtk-theme together. --appearance-only caused prefer-light/prefer-dark + // to diverge from gtk-theme (e.g. adw-gtk3 vs adw-gtk3-dark), which GTK reads as inverted. function pushSystemColorScheme() { if (!Settings.data.colorSchemes.syncGsettings) return; const mode = Settings.data.colorSchemes.darkMode ? "dark" : "light"; - Quickshell.execDetached(["python3", gtkRefreshScript, "--appearance-only", mode]); + Quickshell.execDetached(["python3", gtkRefreshScript, mode]); } Connections {