From edcad60786c7e1d27f20365c4576b5b4af3b0c88 Mon Sep 17 00:00:00 2001 From: bbedward Date: Tue, 21 Jul 2026 11:41:04 -0400 Subject: [PATCH] rebase KDE platform compat --- core/internal/matugen/matugen.go | 45 +++++++++++++++++++ .../Modules/Settings/ThemeColorsTab.qml | 2 +- 2 files changed, 46 insertions(+), 1 deletion(-) diff --git a/core/internal/matugen/matugen.go b/core/internal/matugen/matugen.go index cdd643228..e263ba486 100644 --- a/core/internal/matugen/matugen.go +++ b/core/internal/matugen/matugen.go @@ -390,6 +390,10 @@ func buildOnce(opts *Options) (bool, error) { refreshGTK4() } + if isDMSKDEColorSchemeActive(opts.ConfigDir) { + applyKDEColorScheme(opts.Mode) + } + if !opts.ShouldSkipTemplate("qt6ct") && appExists(opts.AppChecker, []string{"qt6ct"}, nil) { refreshQt6ct() } @@ -923,6 +927,47 @@ func isDMSGTKActive(configDir string) bool { return err == nil && strings.Contains(string(data), "dank-colors.css") } +// isDMSKDEColorSchemeActive only flips the scheme when the user is already on a +// DankMatugen one, leaving Breeze (or anything else) untouched. +func isDMSKDEColorSchemeActive(configDir string) bool { + data, err := os.ReadFile(filepath.Join(configDir, "kdeglobals")) + if err != nil { + return false + } + + inGeneral := false + for _, line := range strings.Split(string(data), "\n") { + line = strings.TrimSpace(line) + if strings.HasPrefix(line, "[") { + inGeneral = line == "[General]" + continue + } + if !inGeneral { + continue + } + if name, ok := strings.CutPrefix(line, "ColorScheme="); ok { + return strings.HasPrefix(strings.TrimSpace(name), "DankMatugen") + } + } + return false +} + +func applyKDEColorScheme(mode ColorMode) { + if !utils.CommandExists("plasma-apply-colorscheme") { + return + } + + scheme := "DankMatugenDark" + if mode == ColorModeLight { + scheme = "DankMatugenLight" + } + + log.Infof("Applying KDE color scheme: %s", scheme) + if err := exec.Command("plasma-apply-colorscheme", scheme).Run(); err != nil { + log.Warnf("Failed to apply KDE color scheme: %v", err) + } +} + func refreshGTK(mode ColorMode) { if err := utils.GsettingsSet("org.gnome.desktop.interface", "gtk-theme", ""); err != nil { log.Warnf("Failed to reset gtk-theme: %v", err) diff --git a/quickshell/Modules/Settings/ThemeColorsTab.qml b/quickshell/Modules/Settings/ThemeColorsTab.qml index 721d17cbb..b49d45fd3 100644 --- a/quickshell/Modules/Settings/ThemeColorsTab.qml +++ b/quickshell/Modules/Settings/ThemeColorsTab.qml @@ -210,7 +210,7 @@ Item { } function warnIfMissingQtTheme() { - if (Quickshell.env("QT_QPA_PLATFORMTHEME") === "gtk3" || Quickshell.env("QT_QPA_PLATFORMTHEME") === "qt6ct" || Quickshell.env("QT_QPA_PLATFORMTHEME_QT6") === "qt6ct") + if (Quickshell.env("QT_QPA_PLATFORMTHEME") === "gtk3" || Quickshell.env("QT_QPA_PLATFORMTHEME") === "qt6ct" || Quickshell.env("QT_QPA_PLATFORMTHEME_QT6") === "qt6ct" || Quickshell.env("QT_QPA_PLATFORMTHEME") === "kde") return; ToastService.showError(I18n.tr("Missing Environment Variables", "qt theme env error title"), I18n.tr("You need to set either:\nQT_QPA_PLATFORMTHEME=gtk3 OR\nQT_QPA_PLATFORMTHEME=qt6ct\nas environment variables, and then restart the shell.\n\nqt6ct requires qt6ct-kde to be installed.", "qt theme env error body")); }