1
0
mirror of https://github.com/AvengeMedia/DankMaterialShell.git synced 2026-01-24 13:32:50 -05:00

allow overriding matugen type in custom themes

This commit is contained in:
bbedward
2025-09-21 22:31:45 -04:00
parent f38ffa1de5
commit 81550229e8
4 changed files with 51 additions and 16 deletions

View File

@@ -297,7 +297,8 @@ const StockThemes = {
backgroundText: "#e4e2e3",
outline: "#929092",
surfaceContainer: "#2a2a2a",
surfaceContainerHigh: "#2a2a2b"
surfaceContainerHigh: "#2a2a2b",
matugen_type: "scheme-monochrome"
}
},
LIGHT: {
@@ -486,7 +487,8 @@ const StockThemes = {
backgroundText: "#e4e2e3",
outline: "#929092",
surfaceContainer: "#1f1f21",
surfaceContainerHigh: "#2a2a2b"
surfaceContainerHigh: "#2a2a2b",
matugen_type: "scheme-monochrome"
}
}
}

View File

@@ -505,7 +505,7 @@ Singleton {
}
}
function setDesiredTheme(kind, value, isLight, iconTheme) {
function setDesiredTheme(kind, value, isLight, iconTheme, matugenType) {
if (!matugenAvailable) {
console.warn("matugen not available - cannot set system theme")
return
@@ -515,7 +515,8 @@ Singleton {
"kind": kind,
"value": value,
"mode": isLight ? "light" : "dark",
"iconTheme": iconTheme || "System Default"
"iconTheme": iconTheme || "System Default",
"matugenType": matugenType || "scheme-tonal-spot"
}
const json = JSON.stringify(desired)
@@ -553,21 +554,24 @@ Singleton {
}
} else {
let primaryColor
let matugenType
if (currentTheme === "custom") {
if (!customThemeData || !customThemeData.primary) {
console.warn("Custom theme data not available for system theme generation")
return
}
primaryColor = customThemeData.primary
matugenType = customThemeData.matugen_type
} else {
primaryColor = currentThemeData.primary
matugenType = currentThemeData.matugen_type
}
if (!primaryColor) {
console.warn("No primary color available for theme:", currentTheme)
return
}
setDesiredTheme("hex", primaryColor, isLight, iconTheme)
setDesiredTheme("hex", primaryColor, isLight, iconTheme, matugenType)
}
}
@@ -686,17 +690,20 @@ Singleton {
}
} else {
let primaryColor
let matugenType
if (currentTheme === "custom") {
if (customThemeData && customThemeData.primary) {
primaryColor = customThemeData.primary
matugenType = customThemeData.matugen_type
}
} else {
primaryColor = currentThemeData.primary
matugenType = currentThemeData.matugen_type
}
if (primaryColor) {
Quickshell.execDetached(["rm", "-f", stateDir + "/matugen.key"])
setDesiredTheme("hex", primaryColor, isLight, iconTheme)
setDesiredTheme("hex", primaryColor, isLight, iconTheme, matugenType)
}
}
}

View File

@@ -30,7 +30,8 @@ These are the essential colors that define your theme's appearance:
"surfaceContainerHigh": "#264026",
"error": "#FF0066",
"warning": "#CCFF00",
"info": "#00FFCC"
"info": "#00FFCC",
"matugen_type": "scheme-expressive"
},
"light": {
"name": "Cyberpunk Electric Light",
@@ -50,7 +51,8 @@ These are the essential colors that define your theme's appearance:
"surfaceContainerHigh": "#EBFFEB",
"error": "#B3004D",
"warning": "#99CC00",
"info": "#00B899"
"info": "#00B899",
"matugen_type": "scheme-expressive"
}
}
```
@@ -119,6 +121,25 @@ While the core colors above are required, you can also customize these optional
- `warning` - Used for warning states and caution indicators
- `info` - Used for informational states and neutral indicators
### Matugen Color Scheme Type
```json
{
"matugen_type": "scheme-monochrome"
}
```
- `matugen_type` - Controls the color scheme algorithm used by matugen for system app theming
- **Default**: `scheme-tonal-spot` (if not specified)
- **Available options**:
- `scheme-content` - Content-based color extraction
- `scheme-expressive` - Expressive, vibrant color schemes
- `scheme-fidelity` - High fidelity to source material
- `scheme-fruit-salad` - Colorful, fruit salad-like schemes
- `scheme-monochrome` - Monochromatic color schemes
- `scheme-neutral` - Neutral, subdued color schemes
- `scheme-rainbow` - Rainbow-like color schemes
- `scheme-tonal-spot` - Tonal spot color schemes (default)
## Setting Custom Theme
In settings -> Theme & Colors you can choose "Custom" to choose a path to your theme.

View File

@@ -46,18 +46,22 @@ key_of() {
local value=$(echo "$json" | sed 's/.*"value": *"\([^"]*\)".*/\1/')
local mode=$(echo "$json" | sed 's/.*"mode": *"\([^"]*\)".*/\1/')
local icon=$(echo "$json" | sed 's/.*"iconTheme": *"\([^"]*\)".*/\1/')
local matugen_type=$(echo "$json" | sed 's/.*"matugenType": *"\([^"]*\)".*/\1/')
[[ -z "$icon" ]] && icon="System Default"
echo "${kind}|${value}|${mode}|${icon}" | sha256sum | cut -d' ' -f1
[[ -z "$matugen_type" ]] && matugen_type="scheme-tonal-spot"
echo "${kind}|${value}|${mode}|${icon}|${matugen_type}" | sha256sum | cut -d' ' -f1
}
build_once() {
local json="$1"
local kind value mode icon
local kind value mode icon matugen_type
kind=$(echo "$json" | sed 's/.*"kind": *"\([^"]*\)".*/\1/')
value=$(echo "$json" | sed 's/.*"value": *"\([^"]*\)".*/\1/')
mode=$(echo "$json" | sed 's/.*"mode": *"\([^"]*\)".*/\1/')
icon=$(echo "$json" | sed 's/.*"iconTheme": *"\([^"]*\)".*/\1/')
matugen_type=$(echo "$json" | sed 's/.*"matugenType": *"\([^"]*\)".*/\1/')
[[ -z "$icon" ]] && icon="System Default"
[[ -z "$matugen_type" ]] && matugen_type="scheme-tonal-spot"
CONFIG_DIR="${CONFIG_DIR:-$HOME/.config}"
@@ -94,17 +98,18 @@ build_once() {
pushd "$SHELL_DIR" >/dev/null
MAT_MODE=(-m "$mode")
MAT_TYPE=(-t "$matugen_type")
case "$kind" in
image)
[[ -f "$value" ]] || { echo "wallpaper not found: $value" >&2; popd >/dev/null; return 2; }
JSON=$(matugen -c "$TMP_CFG" --json hex image "$value" "${MAT_MODE[@]}")
matugen -c "$TMP_CFG" image "$value" "${MAT_MODE[@]}" >/dev/null
JSON=$(matugen -c "$TMP_CFG" --json hex image "$value" "${MAT_MODE[@]}" "${MAT_TYPE[@]}")
matugen -c "$TMP_CFG" image "$value" "${MAT_MODE[@]}" "${MAT_TYPE[@]}" >/dev/null
;;
hex)
[[ "$value" =~ ^#[0-9A-Fa-f]{6}$ ]] || { echo "invalid hex: $value" >&2; popd >/dev/null; return 2; }
JSON=$(matugen -c "$TMP_CFG" --json hex color hex "$value" "${MAT_MODE[@]}")
matugen -c "$TMP_CFG" color hex "$value" "${MAT_MODE[@]}" >/dev/null
JSON=$(matugen -c "$TMP_CFG" --json hex color hex "$value" "${MAT_MODE[@]}" "${MAT_TYPE[@]}")
matugen -c "$TMP_CFG" color hex "$value" "${MAT_MODE[@]}" "${MAT_TYPE[@]}" >/dev/null
;;
*)
echo "unknown kind: $kind" >&2; popd >/dev/null; return 2;;
@@ -135,10 +140,10 @@ build_once() {
if [[ -s "$TMP_CONTENT_CFG" ]] && grep -q '\[templates\.' "$TMP_CONTENT_CFG"; then
case "$kind" in
image)
matugen -c "$TMP_CONTENT_CFG" image "$value" "${MAT_MODE[@]}" >/dev/null
matugen -c "$TMP_CONTENT_CFG" image "$value" "${MAT_MODE[@]}" "${MAT_TYPE[@]}" >/dev/null
;;
hex)
matugen -c "$TMP_CONTENT_CFG" color hex "$value" "${MAT_MODE[@]}" >/dev/null
matugen -c "$TMP_CONTENT_CFG" color hex "$value" "${MAT_MODE[@]}" "${MAT_TYPE[@]}" >/dev/null
;;
esac
fi