Matugen: fix spicetify theme work for predefined colors && fix hex_stripped does not work

This commit is contained in:
Aiser
2025-11-10 22:30:22 +08:00
parent 85ff0532fa
commit e3aa6e3429
2 changed files with 38 additions and 32 deletions
+26 -26
View File
@@ -1,27 +1,27 @@
[Comfy] [Comfy]
text = {{ colors.on_surface.default.hex_stripped }} text = {{colors.on_surface.default.hex_stripped}}
subtext = {{ colors.on_surface_variant.default.hex_stripped }} subtext = {{colors.on_surface_variant.default.hex_stripped}}
main = {{ colors.surface.default.hex_stripped }} main = {{colors.surface.default.hex_stripped}}
main-elevated = {{ colors.surface_bright.default.hex_stripped }} main-elevated = {{colors.surface.default.hex_stripped}}
main-transition = {{ colors.surface_container_lowest.default.hex_stripped }} main-transition = {{colors.surface_container_lowest.default.hex_stripped}}
highlight = {{ colors.surface_container_low.default.hex_stripped }} highlight = {{colors.surface_container_low.default.hex_stripped}}
highlight-elevated = {{ colors.surface_container_highest.default.hex_stripped }} highlight-elevated = {{colors.surface_container_highest.default.hex_stripped}}
sidebar = {{ colors.surface.default.hex_stripped }} sidebar = {{colors.surface.default.hex_stripped}}
player = {{ colors.scrim.default.hex_stripped }} player = {{colors.surface.default.hex_stripped}}
card = {{ colors.scrim.default.hex_stripped }} card = {{colors.surface.default.hex_stripped}}
shadow = {{ colors.scrim.default.hex_stripped }} shadow = {{colors.surface.default.hex_stripped}}
selected-row = {{ colors.on_surface.default.hex_stripped }} selected-row = {{colors.on_surface.default.hex_stripped}}
button = {{ colors.primary.default.hex_stripped }} button = {{colors.primary.default.hex_stripped}}
button-active = {{ colors.primary_fixed.default.hex_stripped }} button-active = {{colors.primary.default.hex_stripped}}
button-disabled = {{ colors.primary_fixed_dim.default.hex_stripped }} button-disabled = {{colors.primary.default.hex_stripped}}
tab-active = {{ colors.surface.default.hex_stripped }} tab-active = {{colors.surface.default.hex_stripped}}
notification = {{ colors.tertiary.default.hex_stripped }} notification = {{colors.tertiary.default.hex_stripped}}
notification-error = {{ colors.error.default.hex_stripped }} notification-error = {{colors.error.default.hex_stripped}}
misc = {{ colors.scrim.default.hex_stripped }} misc = {{colors.surface.default.hex_stripped}}
play-button = {{ colors.secondary.default.hex_stripped }} play-button = {{colors.secondary.default.hex_stripped}}
play-button-active = {{ colors.secondary_fixed.default.hex_stripped }} play-button-active = {{colors.secondary.default.hex_stripped}}
progress-fg = {{ colors.primary.default.hex_stripped }} progress-fg = {{colors.primary.default.hex_stripped}}
progress-bg = {{ colors.surface.default.hex_stripped }} progress-bg = {{colors.surface.default.hex_stripped}}
heart = {{ colors.error.default.hex_stripped }} heart = {{colors.error.default.hex_stripped}}
pagelink-active = {{ colors.on_tertiary_container.default.hex_stripped }} pagelink-active = {{colors.on_tertiary_container.default.hex_stripped}}
radio-btn-active = {{ colors.on_tertiary_container.default.hex_stripped }} radio-btn-active = {{colors.on_tertiary_container.default.hex_stripped}}
+12 -6
View File
@@ -222,14 +222,20 @@ Singleton {
} }
function replaceColorsInFile(filePath, colors) { function replaceColorsInFile(filePath, colors) {
// This handles both ".hex" and ".hex_stripped" the EXACT same way. Our predefined color schemes are
// always RRGGBB without alpha so this is fine and keeps compatibility with matugen.
let script = "" let script = ""
Object.keys(colors).forEach(colorKey => { Object.keys(colors).forEach(colorKey => {
const colorValue = colors[colorKey].default.hex const hexValue = colors[colorKey].default.hex
const escapedColor = colorValue.replace(/[.*+?^${}()|[\]\\]/g, '\\$&') const hexStrippedValue = colors[colorKey].default.hex_stripped
script += `sed -i 's/{{colors\\.${colorKey}\\.default\\.hex\\(_stripped\\)\\?}}/${escapedColor}/g' '${filePath}'\n`
}) const escapedHex = hexValue.replace(/[.*+?^${}()|[\]\\]/g, '\\$&')
const escapedHexStripped = hexStrippedValue.replace(/[.*+?^${}()|[\]\\]/g, '\\$&')
// replace hex_stripped
script += `sed -i 's/{{colors\\.${colorKey}\\.default\\.hex_stripped}}/${escapedHexStripped}/g' '${filePath}'\n`
// replace hex
script += `sed -i 's/{{colors\\.${colorKey}\\.default\\.hex}}/${escapedHex}/g' '${filePath}'\n`
})
return script return script
} }