1
0
mirror of https://github.com/AvengeMedia/DankMaterialShell.git synced 2025-12-07 22:15:38 -05:00

fix qt auto-theme

This commit is contained in:
bbedward
2025-08-01 08:06:21 -04:00
parent ce9f4efb5d
commit be6ef5fc77
7 changed files with 126 additions and 89 deletions

View File

@@ -292,12 +292,16 @@ palette = 15=${fg_b}`;
// Get current theme preferences
const isLight = (typeof Theme !== "undefined" && Theme.isLightMode) ? "true" : "false";
const iconTheme = (typeof Prefs !== "undefined" && Prefs.iconTheme) ? Prefs.iconTheme : "System Default";
const gtkTheming = (typeof Prefs !== "undefined" && Prefs.gtkThemingEnabled) ? "true" : "false";
const qtTheming = (typeof Prefs !== "undefined" && Prefs.qtThemingEnabled) ? "true" : "false";
console.log("Theme mode:", isLight === "true" ? "light" : "dark");
console.log("Icon theme:", iconTheme);
console.log("GTK theming enabled:", gtkTheming);
console.log("Qt theming enabled:", qtTheming);
systemThemeGenerationInProgress = true;
systemThemeGenerator.command = [shellDir + "/generate-themes.sh", wallpaperPath, shellDir, homeDir, "generate", isLight, iconTheme];
systemThemeGenerator.command = [shellDir + "/generate-themes.sh", wallpaperPath, shellDir, homeDir, "generate", isLight, iconTheme, gtkTheming, qtTheming];
systemThemeGenerator.running = true;
}
@@ -323,11 +327,15 @@ palette = 15=${fg_b}`;
// Get current theme preferences
const isLight = (typeof Theme !== "undefined" && Theme.isLightMode) ? "true" : "false";
const iconTheme = (typeof Prefs !== "undefined" && Prefs.iconTheme) ? Prefs.iconTheme : "System Default";
const gtkTheming = (typeof Prefs !== "undefined" && Prefs.gtkThemingEnabled) ? "true" : "false";
const qtTheming = (typeof Prefs !== "undefined" && Prefs.qtThemingEnabled) ? "true" : "false";
console.log("Restoring to theme mode:", isLight === "true" ? "light" : "dark");
console.log("Icon theme:", iconTheme);
console.log("GTK theming enabled:", gtkTheming);
console.log("Qt theming enabled:", qtTheming);
systemThemeRestoreProcess.command = [shellDir + "/generate-themes.sh", "", shellDir, homeDir, "restore", isLight, iconTheme];
systemThemeRestoreProcess.command = [shellDir + "/generate-themes.sh", "", shellDir, homeDir, "restore", isLight, iconTheme, gtkTheming, qtTheming];
systemThemeRestoreProcess.running = true;
}

View File

@@ -545,6 +545,7 @@ Singleton {
Quickshell.execDetached(["sh", "-lc", script]);
}
function applyStoredIconTheme() {
updateGtkIconTheme(iconTheme);
updateQtIconTheme(iconTheme);

View File

@@ -96,6 +96,12 @@ sudo dnf copr enable heus-sueh/packages && sudo dnf install matugen
gtk-theme-name=Colloid
```
**Recommended QT base them:** Breeze is recommended, on arch it can be installed with `pacman -S breeze breeze5` and then in `~/.confg/qt6ct/qt6ct.conf` and `~/.confg/qt5ct/qt5ct.conf` set the following:
```
[Appearance]
style=Breeze
```
Enable these features in Settings → Appearance → System App Theming after installing the dependencies.
3. Install DankMaterialShell

View File

@@ -9,9 +9,11 @@ HOME_DIR="$3"
MODE="$4" # "generate" or "restore"
IS_LIGHT="$5" # "true" for light mode, "false" for dark mode
ICON_THEME="$6" # Icon theme name
GTK_THEMING="$7" # "true" to enable GTK theming, "false" to disable
QT_THEMING="$8" # "true" to enable Qt theming, "false" to disable
if [ -z "$SHELL_DIR" ] || [ -z "$HOME_DIR" ]; then
echo "Usage: $0 <wallpaper_path> <shell_dir> <home_dir> [mode] [is_light] [icon_theme]" >&2
echo "Usage: $0 <wallpaper_path> <shell_dir> <home_dir> [mode] [is_light] [icon_theme] [gtk_theming] [qt_theming]" >&2
echo " For restore mode, wallpaper_path can be empty" >&2
exit 1
fi
@@ -20,6 +22,8 @@ fi
MODE=${MODE:-"generate"}
IS_LIGHT=${IS_LIGHT:-"false"}
ICON_THEME=${ICON_THEME:-"System Default"}
GTK_THEMING=${GTK_THEMING:-"false"}
QT_THEMING=${QT_THEMING:-"false"}
update_theme_settings() {
local color_scheme="$1"
@@ -84,6 +88,75 @@ update_gtk_css() {
echo "Updated GTK-3.0 CSS import"
}
update_qt_config() {
local home_dir="$1"
local username=$(basename "$home_dir")
echo "Updating Qt configuration..."
# Function to update Qt config files with color scheme settings
update_qt_color_config() {
local config_file="$1"
local version="$2"
local color_scheme_path="$home_dir/.config/qt${version}ct/colors/matugen.conf"
if [ -f "$config_file" ]; then
# Update existing config with awk - properly handle existing [Appearance] section
awk -v scheme_path="$color_scheme_path" '
BEGIN { in_appearance = 0; custom_palette_set = 0; color_scheme_set = 0 }
/^\[Appearance\]/ {
in_appearance = 1;
print;
next
}
/^\[/ && !/^\[Appearance\]/ {
# End of [Appearance] section - add missing settings before next section
if (in_appearance) {
if (!custom_palette_set) { print "custom_palette=true" }
if (!color_scheme_set) { print "color_scheme_path=" scheme_path }
}
in_appearance = 0;
print;
next
}
in_appearance && /^custom_palette=/ {
print "custom_palette=true"
custom_palette_set = 1
next
}
in_appearance && /^color_scheme_path=/ {
print "color_scheme_path=" scheme_path
color_scheme_set = 1
next
}
{ print }
END {
# Handle case where [Appearance] is the last section
if (in_appearance) {
if (!custom_palette_set) print "custom_palette=true"
if (!color_scheme_set) print "color_scheme_path=" scheme_path
}
}
' "$config_file" > "$config_file.tmp" && mv "$config_file.tmp" "$config_file"
else
# Create new config file
printf '[Appearance]\ncustom_palette=true\ncolor_scheme_path=%s\n' "$color_scheme_path" > "$config_file"
fi
}
# Update Qt5ct if available
if command -v qt5ct >/dev/null 2>&1; then
update_qt_color_config "$home_dir/.config/qt5ct/qt5ct.conf" "5"
echo "Updated Qt5ct configuration"
fi
# Update Qt6ct if available
if command -v qt6ct >/dev/null 2>&1; then
update_qt_color_config "$home_dir/.config/qt6ct/qt6ct.conf" "6"
echo "Updated Qt6ct configuration"
fi
}
# Handle restore mode
if [ "$MODE" = "restore" ]; then
echo "Restoring default theme settings..."
@@ -143,8 +216,26 @@ fi
update_theme_settings "$color_scheme" "$ICON_THEME"
# Update GTK CSS imports
# Update GTK CSS imports if GTK theming is enabled
if [ "$GTK_THEMING" = "true" ]; then
update_gtk_css "$HOME_DIR"
echo "GTK theming updated"
else
echo "GTK theming disabled - skipping GTK CSS updates"
fi
# Update Qt configuration if Qt theming is enabled
if [ "$QT_THEMING" = "true" ]; then
update_qt_config "$HOME_DIR"
echo "Qt theming updated"
else
echo "Qt theming disabled - skipping Qt configuration updates"
fi
echo "System theme files generated successfully"
if [ "$GTK_THEMING" = "true" ]; then
echo "dank-colors.css files should be available in $HOME_DIR/.config/gtk-3.0/ and $HOME_DIR/.config/gtk-4.0/"
fi
if [ "$QT_THEMING" = "true" ]; then
echo "Qt color schemes should be available in $HOME_DIR/.config/qt5ct/colors/ and $HOME_DIR/.config/qt6ct/colors/"
fi

View File

@@ -11,3 +11,11 @@ output_path = '~/.config/gtk-4.0/dank-colors.css'
[templates.qt]
input_path = './templates/qt-colors.colors'
output_path = '~/.local/share/color-schemes/Matugen.colors'
[templates.qt5ct]
input_path = './templates/qtct-colors.conf'
output_path = '~/.config/qt5ct/colors/matugen.conf'
[templates.qt6ct]
input_path = './templates/qtct-colors.conf'
output_path = '~/.config/qt6ct/colors/matugen.conf'

View File

@@ -1,82 +0,0 @@
[ColorEffects:Disabled]
Color={{colors.surface_dim.default.hex}}
ColorAmount=0
ColorEffect=0
ContrastAmount=0.65
ContrastEffect=1
IntensityAmount=0.1
IntensityEffect=2
[ColorEffects:Inactive]
ChangeSelectionColor=true
Color={{colors.surface_variant.default.hex}}
ColorAmount=0.025
ColorEffect=2
ContrastAmount=0.1
ContrastEffect=2
Enable=false
IntensityAmount=0
IntensityEffect=0
[Colors:Button]
BackgroundAlternate={{colors.surface_container_low.default.hex}}
BackgroundNormal={{colors.surface_container_high.default.hex}}
DecorationFocus={{colors.primary.default.hex}}
DecorationHover={{colors.primary.default.hex}}
ForegroundActive={{colors.primary.default.hex}}
ForegroundInactive={{colors.on_surface_variant.default.hex}}
ForegroundLink={{colors.secondary.default.hex}}
ForegroundNegative={{colors.error.default.hex}}
ForegroundNeutral={{colors.tertiary.default.hex}}
ForegroundNormal={{colors.on_surface.default.hex}}
ForegroundPositive={{colors.tertiary_fixed.default.hex}}
ForegroundVisited={{colors.on_secondary_container.default.hex}}
[Colors:Selection]
BackgroundAlternate={{colors.surface_container_low.default.hex}}
BackgroundNormal={{colors.primary.default.hex}}
DecorationFocus={{colors.primary.default.hex}}
DecorationHover={{colors.primary.default.hex}}
ForegroundActive={{colors.on_primary.default.hex}}
ForegroundInactive={{colors.on_surface_variant.default.hex}}
ForegroundLink={{colors.secondary_fixed.default.hex}}
ForegroundNegative={{colors.error_container.default.hex}}
ForegroundNeutral={{colors.tertiary_fixed_dim.default.hex}}
ForegroundNormal={{colors.on_primary.default.hex}}
ForegroundPositive={{colors.tertiary_container.default.hex}}
ForegroundVisited={{colors.on_secondary_container.default.hex}}
[Colors:View]
BackgroundAlternate={{colors.surface_container.default.hex}}
BackgroundNormal={{colors.background.default.hex}}
DecorationFocus={{colors.on_primary_container.default.hex}}
DecorationHover={{colors.on_primary.default.hex}}
ForegroundActive={{colors.primary.default.hex}}
ForegroundInactive={{colors.on_surface_variant.default.hex}}
ForegroundLink={{colors.secondary.default.hex}}
ForegroundNegative={{colors.error.default.hex}}
ForegroundNeutral={{colors.tertiary.default.hex}}
ForegroundNormal={{colors.on_background.default.hex}}
ForegroundPositive={{colors.tertiary_fixed.default.hex}}
ForegroundVisited={{colors.on_secondary_container.default.hex}}
[Colors:Window]
BackgroundAlternate={{colors.primary_container.default.hex}}
BackgroundNormal={{colors.surface_container.default.hex}}
DecorationFocus={{colors.primary.default.hex}}
DecorationHover={{colors.primary.default.hex}}
ForegroundActive={{colors.primary.default.hex}}
ForegroundInactive={{colors.on_surface_variant.default.hex}}
ForegroundLink={{colors.secondary.default.hex}}
ForegroundNegative={{colors.error.default.hex}}
ForegroundNeutral={{colors.tertiary.default.hex}}
ForegroundNormal={{colors.on_background.default.hex}}
ForegroundPositive={{colors.tertiary_fixed.default.hex}}
ForegroundVisited={{colors.on_secondary_container.default.hex}}
[General]
ColorScheme=Matugen
Name=Matugen
[KDE]
contrast=4

View File

@@ -0,0 +1,5 @@
[ColorScheme]
active_colors={{colors.on_background.default.hex}}, {{colors.surface.default.hex}}, #ffffff, #cacaca, #9f9f9f, #b8b8b8, {{colors.on_background.default.hex}}, #ffffff, {{colors.on_surface.default.hex}}, {{colors.background.default.hex}}, {{colors.background.default.hex}}, {{colors.shadow.default.hex}}, {{colors.primary_container.default.hex}}, {{colors.on_primary_container.default.hex}}, {{colors.secondary.default.hex}}, {{colors.primary.default.hex}}, {{colors.surface.default.hex}}, {{colors.scrim.default.hex}}, {{colors.surface.default.hex}}, {{colors.on_surface.default.hex}}, {{colors.secondary.default.hex}}
disabled_colors={{colors.on_background.default.hex}}, {{colors.surface.default.hex}}, #ffffff, #cacaca, #9f9f9f, #b8b8b8, {{colors.on_background.default.hex}}, #ffffff, {{colors.on_surface.default.hex}}, {{colors.background.default.hex}}, {{colors.background.default.hex}}, {{colors.shadow.default.hex}}, {{colors.primary_container.default.hex}}, {{colors.on_primary_container.default.hex}}, {{colors.secondary.default.hex}}, {{colors.primary.default.hex}}, {{colors.surface.default.hex}}, {{colors.scrim.default.hex}}, {{colors.surface.default.hex}}, {{colors.on_surface.default.hex}}, {{colors.secondary.default.hex}}
inactive_colors={{colors.on_background.default.hex}}, {{colors.surface.default.hex}}, #ffffff, #cacaca, #9f9f9f, #b8b8b8, {{colors.on_background.default.hex}}, #ffffff, {{colors.on_surface.default.hex}}, {{colors.background.default.hex}}, {{colors.background.default.hex}}, {{colors.shadow.default.hex}}, {{colors.primary_container.default.hex}}, {{colors.on_primary_container.default.hex}}, {{colors.secondary.default.hex}}, {{colors.primary.default.hex}}, {{colors.surface.default.hex}}, {{colors.scrim.default.hex}}, {{colors.surface.default.hex}}, {{colors.on_surface.default.hex}}, {{colors.secondary.default.hex}}