mirror of
https://github.com/noctalia-dev/noctalia-shell.git
synced 2026-05-11 17:08:27 +08:00
fix(theming): sync gtk-theme with color-scheme when system sync is on
This commit is contained in:
@@ -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)
|
||||
|
||||
|
||||
|
||||
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user