1
0
mirror of https://github.com/AvengeMedia/DankMaterialShell.git synced 2026-01-24 21:42:51 -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", backgroundText: "#e4e2e3",
outline: "#929092", outline: "#929092",
surfaceContainer: "#2a2a2a", surfaceContainer: "#2a2a2a",
surfaceContainerHigh: "#2a2a2b" surfaceContainerHigh: "#2a2a2b",
matugen_type: "scheme-monochrome"
} }
}, },
LIGHT: { LIGHT: {
@@ -486,7 +487,8 @@ const StockThemes = {
backgroundText: "#e4e2e3", backgroundText: "#e4e2e3",
outline: "#929092", outline: "#929092",
surfaceContainer: "#1f1f21", 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) { if (!matugenAvailable) {
console.warn("matugen not available - cannot set system theme") console.warn("matugen not available - cannot set system theme")
return return
@@ -515,7 +515,8 @@ Singleton {
"kind": kind, "kind": kind,
"value": value, "value": value,
"mode": isLight ? "light" : "dark", "mode": isLight ? "light" : "dark",
"iconTheme": iconTheme || "System Default" "iconTheme": iconTheme || "System Default",
"matugenType": matugenType || "scheme-tonal-spot"
} }
const json = JSON.stringify(desired) const json = JSON.stringify(desired)
@@ -553,21 +554,24 @@ Singleton {
} }
} else { } else {
let primaryColor let primaryColor
let matugenType
if (currentTheme === "custom") { if (currentTheme === "custom") {
if (!customThemeData || !customThemeData.primary) { if (!customThemeData || !customThemeData.primary) {
console.warn("Custom theme data not available for system theme generation") console.warn("Custom theme data not available for system theme generation")
return return
} }
primaryColor = customThemeData.primary primaryColor = customThemeData.primary
matugenType = customThemeData.matugen_type
} else { } else {
primaryColor = currentThemeData.primary primaryColor = currentThemeData.primary
matugenType = currentThemeData.matugen_type
} }
if (!primaryColor) { if (!primaryColor) {
console.warn("No primary color available for theme:", currentTheme) console.warn("No primary color available for theme:", currentTheme)
return return
} }
setDesiredTheme("hex", primaryColor, isLight, iconTheme) setDesiredTheme("hex", primaryColor, isLight, iconTheme, matugenType)
} }
} }
@@ -686,17 +690,20 @@ Singleton {
} }
} else { } else {
let primaryColor let primaryColor
let matugenType
if (currentTheme === "custom") { if (currentTheme === "custom") {
if (customThemeData && customThemeData.primary) { if (customThemeData && customThemeData.primary) {
primaryColor = customThemeData.primary primaryColor = customThemeData.primary
matugenType = customThemeData.matugen_type
} }
} else { } else {
primaryColor = currentThemeData.primary primaryColor = currentThemeData.primary
matugenType = currentThemeData.matugen_type
} }
if (primaryColor) { if (primaryColor) {
Quickshell.execDetached(["rm", "-f", stateDir + "/matugen.key"]) 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", "surfaceContainerHigh": "#264026",
"error": "#FF0066", "error": "#FF0066",
"warning": "#CCFF00", "warning": "#CCFF00",
"info": "#00FFCC" "info": "#00FFCC",
"matugen_type": "scheme-expressive"
}, },
"light": { "light": {
"name": "Cyberpunk Electric Light", "name": "Cyberpunk Electric Light",
@@ -50,7 +51,8 @@ These are the essential colors that define your theme's appearance:
"surfaceContainerHigh": "#EBFFEB", "surfaceContainerHigh": "#EBFFEB",
"error": "#B3004D", "error": "#B3004D",
"warning": "#99CC00", "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 - `warning` - Used for warning states and caution indicators
- `info` - Used for informational states and neutral 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 ## Setting Custom Theme
In settings -> Theme & Colors you can choose "Custom" to choose a path to your 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 value=$(echo "$json" | sed 's/.*"value": *"\([^"]*\)".*/\1/')
local mode=$(echo "$json" | sed 's/.*"mode": *"\([^"]*\)".*/\1/') local mode=$(echo "$json" | sed 's/.*"mode": *"\([^"]*\)".*/\1/')
local icon=$(echo "$json" | sed 's/.*"iconTheme": *"\([^"]*\)".*/\1/') local icon=$(echo "$json" | sed 's/.*"iconTheme": *"\([^"]*\)".*/\1/')
local matugen_type=$(echo "$json" | sed 's/.*"matugenType": *"\([^"]*\)".*/\1/')
[[ -z "$icon" ]] && icon="System Default" [[ -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() { build_once() {
local json="$1" local json="$1"
local kind value mode icon local kind value mode icon matugen_type
kind=$(echo "$json" | sed 's/.*"kind": *"\([^"]*\)".*/\1/') kind=$(echo "$json" | sed 's/.*"kind": *"\([^"]*\)".*/\1/')
value=$(echo "$json" | sed 's/.*"value": *"\([^"]*\)".*/\1/') value=$(echo "$json" | sed 's/.*"value": *"\([^"]*\)".*/\1/')
mode=$(echo "$json" | sed 's/.*"mode": *"\([^"]*\)".*/\1/') mode=$(echo "$json" | sed 's/.*"mode": *"\([^"]*\)".*/\1/')
icon=$(echo "$json" | sed 's/.*"iconTheme": *"\([^"]*\)".*/\1/') icon=$(echo "$json" | sed 's/.*"iconTheme": *"\([^"]*\)".*/\1/')
matugen_type=$(echo "$json" | sed 's/.*"matugenType": *"\([^"]*\)".*/\1/')
[[ -z "$icon" ]] && icon="System Default" [[ -z "$icon" ]] && icon="System Default"
[[ -z "$matugen_type" ]] && matugen_type="scheme-tonal-spot"
CONFIG_DIR="${CONFIG_DIR:-$HOME/.config}" CONFIG_DIR="${CONFIG_DIR:-$HOME/.config}"
@@ -94,17 +98,18 @@ build_once() {
pushd "$SHELL_DIR" >/dev/null pushd "$SHELL_DIR" >/dev/null
MAT_MODE=(-m "$mode") MAT_MODE=(-m "$mode")
MAT_TYPE=(-t "$matugen_type")
case "$kind" in case "$kind" in
image) image)
[[ -f "$value" ]] || { echo "wallpaper not found: $value" >&2; popd >/dev/null; return 2; } [[ -f "$value" ]] || { echo "wallpaper not found: $value" >&2; popd >/dev/null; return 2; }
JSON=$(matugen -c "$TMP_CFG" --json hex image "$value" "${MAT_MODE[@]}") JSON=$(matugen -c "$TMP_CFG" --json hex image "$value" "${MAT_MODE[@]}" "${MAT_TYPE[@]}")
matugen -c "$TMP_CFG" image "$value" "${MAT_MODE[@]}" >/dev/null matugen -c "$TMP_CFG" image "$value" "${MAT_MODE[@]}" "${MAT_TYPE[@]}" >/dev/null
;; ;;
hex) hex)
[[ "$value" =~ ^#[0-9A-Fa-f]{6}$ ]] || { echo "invalid hex: $value" >&2; popd >/dev/null; return 2; } [[ "$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[@]}") JSON=$(matugen -c "$TMP_CFG" --json hex color hex "$value" "${MAT_MODE[@]}" "${MAT_TYPE[@]}")
matugen -c "$TMP_CFG" color hex "$value" "${MAT_MODE[@]}" >/dev/null matugen -c "$TMP_CFG" color hex "$value" "${MAT_MODE[@]}" "${MAT_TYPE[@]}" >/dev/null
;; ;;
*) *)
echo "unknown kind: $kind" >&2; popd >/dev/null; return 2;; 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 if [[ -s "$TMP_CONTENT_CFG" ]] && grep -q '\[templates\.' "$TMP_CONTENT_CFG"; then
case "$kind" in case "$kind" in
image) 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) 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 esac
fi fi