1
0
mirror of https://github.com/AvengeMedia/DankMaterialShell.git synced 2026-08-01 19:18:28 -04:00

theme: support for QT_PLATFORMTHEME=kde

This commit is contained in:
bbedward
2026-07-22 12:20:27 -04:00
parent 237fb57d5e
commit 61510c2186
2 changed files with 46 additions and 1 deletions
+45
View File
@@ -390,6 +390,10 @@ func buildOnce(opts *Options) (bool, error) {
refreshGTK4() refreshGTK4()
} }
if isDMSKDEColorSchemeActive(opts.ConfigDir) {
applyKDEColorScheme(opts.Mode)
}
if !opts.ShouldSkipTemplate("qt6ct") && appExists(opts.AppChecker, []string{"qt6ct"}, nil) { if !opts.ShouldSkipTemplate("qt6ct") && appExists(opts.AppChecker, []string{"qt6ct"}, nil) {
refreshQt6ct() refreshQt6ct()
} }
@@ -923,6 +927,47 @@ func isDMSGTKActive(configDir string) bool {
return err == nil && strings.Contains(string(data), "dank-colors.css") 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) { func refreshGTK(mode ColorMode) {
if err := utils.GsettingsSet("org.gnome.desktop.interface", "gtk-theme", ""); err != nil { if err := utils.GsettingsSet("org.gnome.desktop.interface", "gtk-theme", ""); err != nil {
log.Warnf("Failed to reset gtk-theme: %v", err) log.Warnf("Failed to reset gtk-theme: %v", err)
@@ -210,7 +210,7 @@ Item {
} }
function warnIfMissingQtTheme() { 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; 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")); 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"));
} }