mirror of
https://github.com/AvengeMedia/DankMaterialShell.git
synced 2026-01-29 07:52:50 -05:00
re-work mmatugen meta theming
able to handle more rapid changes now, and colors look better
This commit is contained in:
@@ -125,12 +125,22 @@ Singleton {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function setWallpaper(imagePath) {
|
function setWallpaper(imagePath) {
|
||||||
|
console.log("SessionData.setWallpaper called with:", imagePath)
|
||||||
wallpaperPath = imagePath
|
wallpaperPath = imagePath
|
||||||
saveSettings()
|
saveSettings()
|
||||||
|
|
||||||
if (typeof Theme !== "undefined" && typeof SettingsData !== "undefined"
|
if (typeof Theme !== "undefined") {
|
||||||
&& SettingsData.wallpaperDynamicTheming) {
|
console.log("Theme is available, current theme:", Theme.currentTheme)
|
||||||
Theme.extractColors()
|
// Always extract colors for shell UI if dynamic theming is enabled
|
||||||
|
if (typeof SettingsData !== "undefined" && SettingsData.wallpaperDynamicTheming) {
|
||||||
|
console.log("Dynamic theming enabled, extracting colors")
|
||||||
|
Theme.extractColors()
|
||||||
|
}
|
||||||
|
// Always generate system themes (matugen templates) when wallpaper changes
|
||||||
|
console.log("Calling generateSystemThemesFromCurrentTheme")
|
||||||
|
Theme.generateSystemThemesFromCurrentTheme()
|
||||||
|
} else {
|
||||||
|
console.log("Theme is undefined!")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
151
Common/Theme.qml
151
Common/Theme.qml
@@ -31,12 +31,17 @@ Singleton {
|
|||||||
property bool matugenAvailable: false
|
property bool matugenAvailable: false
|
||||||
property bool gtkThemingEnabled: typeof SettingsData !== "undefined" ? SettingsData.gtkAvailable : false
|
property bool gtkThemingEnabled: typeof SettingsData !== "undefined" ? SettingsData.gtkAvailable : false
|
||||||
property bool qtThemingEnabled: typeof SettingsData !== "undefined" ? (SettingsData.qt5ctAvailable || SettingsData.qt6ctAvailable) : false
|
property bool qtThemingEnabled: typeof SettingsData !== "undefined" ? (SettingsData.qt5ctAvailable || SettingsData.qt6ctAvailable) : false
|
||||||
property bool systemThemeGenerationInProgress: false
|
property var workerRunning: false
|
||||||
property var pendingThemeRequest: null
|
|
||||||
property var matugenColors: ({})
|
property var matugenColors: ({})
|
||||||
property bool extractionRequested: false
|
property bool extractionRequested: false
|
||||||
property int colorUpdateTrigger: 0
|
property int colorUpdateTrigger: 0
|
||||||
property var customThemeData: null
|
property var customThemeData: null
|
||||||
|
|
||||||
|
readonly property string stateDir: {
|
||||||
|
const cacheHome = StandardPaths.writableLocation(StandardPaths.CacheLocation).toString()
|
||||||
|
const path = cacheHome.startsWith("file://") ? cacheHome.substring(7) : cacheHome
|
||||||
|
return path + "/dankshell"
|
||||||
|
}
|
||||||
|
|
||||||
function getMatugenColor(path, fallback) {
|
function getMatugenColor(path, fallback) {
|
||||||
colorUpdateTrigger
|
colorUpdateTrigger
|
||||||
@@ -156,10 +161,6 @@ Singleton {
|
|||||||
property real popupTransparency: typeof SettingsData !== "undefined" && SettingsData.popupTransparency !== undefined ? SettingsData.popupTransparency : 0.92
|
property real popupTransparency: typeof SettingsData !== "undefined" && SettingsData.popupTransparency !== undefined ? SettingsData.popupTransparency : 0.92
|
||||||
|
|
||||||
function switchTheme(themeName, savePrefs = true) {
|
function switchTheme(themeName, savePrefs = true) {
|
||||||
// Clear cached colors when switching themes
|
|
||||||
matugenColors = {}
|
|
||||||
colorUpdateTrigger++
|
|
||||||
|
|
||||||
if (themeName === dynamic) {
|
if (themeName === dynamic) {
|
||||||
currentTheme = dynamic
|
currentTheme = dynamic
|
||||||
extractColors()
|
extractColors()
|
||||||
@@ -356,30 +357,43 @@ Singleton {
|
|||||||
generateSystemThemesFromCurrentTheme()
|
generateSystemThemesFromCurrentTheme()
|
||||||
}
|
}
|
||||||
|
|
||||||
function generateSystemThemes() {
|
function setDesiredTheme(kind, value, isLight, iconTheme) {
|
||||||
if (systemThemeGenerationInProgress || !matugenAvailable || !wallpaperPath)
|
if (!matugenAvailable) {
|
||||||
|
console.warn("matugen not available - cannot set system theme")
|
||||||
return
|
return
|
||||||
|
}
|
||||||
const isLight = (typeof SessionData !== "undefined" && SessionData.isLightMode) ? "true" : "false"
|
|
||||||
const iconTheme = (typeof SettingsData !== "undefined" && SettingsData.iconTheme) ? SettingsData.iconTheme : "System Default"
|
const desired = {
|
||||||
|
"kind": kind,
|
||||||
systemThemeGenerationInProgress = true
|
"value": value,
|
||||||
systemThemeGenerator.command = [shellDir + "/scripts/matugen.sh", wallpaperPath, shellDir, configDir, "generate", isLight, iconTheme]
|
"mode": isLight ? "light" : "dark",
|
||||||
|
"iconTheme": iconTheme || "System Default"
|
||||||
|
}
|
||||||
|
|
||||||
|
const json = JSON.stringify(desired)
|
||||||
|
const desiredPath = stateDir + "/matugen.desired.json"
|
||||||
|
|
||||||
|
Quickshell.execDetached([
|
||||||
|
"sh", "-c",
|
||||||
|
`cat > '${desiredPath}' << 'EOF'\n${json}\nEOF`
|
||||||
|
])
|
||||||
|
workerRunning = true
|
||||||
|
systemThemeGenerator.command = [shellDir + "/scripts/matugen-worker.sh", stateDir, shellDir, "--run"]
|
||||||
systemThemeGenerator.running = true
|
systemThemeGenerator.running = true
|
||||||
}
|
}
|
||||||
|
|
||||||
function generateSystemThemesFromCurrentTheme() {
|
function generateSystemThemesFromCurrentTheme() {
|
||||||
if (!matugenAvailable)
|
if (!matugenAvailable)
|
||||||
return
|
return
|
||||||
|
|
||||||
const isLight = (typeof SessionData !== "undefined" && SessionData.isLightMode) ? "true" : "false"
|
const isLight = (typeof SessionData !== "undefined" && SessionData.isLightMode)
|
||||||
const iconTheme = (typeof SettingsData !== "undefined" && SettingsData.iconTheme) ? SettingsData.iconTheme : "System Default"
|
const iconTheme = (typeof SettingsData !== "undefined" && SettingsData.iconTheme) ? SettingsData.iconTheme : "System Default"
|
||||||
|
|
||||||
let cmd
|
|
||||||
if (currentTheme === dynamic) {
|
if (currentTheme === dynamic) {
|
||||||
if (!wallpaperPath)
|
if (!wallpaperPath) {
|
||||||
return
|
return
|
||||||
cmd = [shellDir + "/scripts/matugen.sh", wallpaperPath, shellDir, configDir, "generate", isLight, iconTheme]
|
}
|
||||||
|
setDesiredTheme("image", wallpaperPath, isLight, iconTheme)
|
||||||
} else {
|
} else {
|
||||||
let primaryColor
|
let primaryColor
|
||||||
if (currentTheme === "custom") {
|
if (currentTheme === "custom") {
|
||||||
@@ -396,38 +410,7 @@ Singleton {
|
|||||||
console.warn("No primary color available for theme:", currentTheme)
|
console.warn("No primary color available for theme:", currentTheme)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
cmd = [shellDir + "/scripts/matugen.sh", primaryColor, shellDir, configDir, "generate-color", isLight, iconTheme]
|
setDesiredTheme("hex", primaryColor, isLight, iconTheme)
|
||||||
}
|
|
||||||
|
|
||||||
// Clear any pending request and queue this new one
|
|
||||||
pendingThemeRequest = {
|
|
||||||
command: cmd,
|
|
||||||
isDynamic: currentTheme === dynamic,
|
|
||||||
timestamp: Date.now()
|
|
||||||
}
|
|
||||||
|
|
||||||
// Clear cached colors to force refresh
|
|
||||||
matugenColors = {}
|
|
||||||
colorUpdateTrigger++
|
|
||||||
|
|
||||||
// Process the queue
|
|
||||||
processThemeQueue()
|
|
||||||
}
|
|
||||||
|
|
||||||
function processThemeQueue() {
|
|
||||||
if (systemThemeGenerationInProgress || !pendingThemeRequest)
|
|
||||||
return
|
|
||||||
|
|
||||||
const request = pendingThemeRequest
|
|
||||||
pendingThemeRequest = null
|
|
||||||
|
|
||||||
systemThemeGenerationInProgress = true
|
|
||||||
systemThemeGenerator.command = request.command
|
|
||||||
systemThemeGenerator.running = true
|
|
||||||
|
|
||||||
if (request.isDynamic) {
|
|
||||||
// Re-extract colors after system theme generation
|
|
||||||
Qt.callLater(extractColors)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -522,6 +505,35 @@ Singleton {
|
|||||||
if (extractionRequested) {
|
if (extractionRequested) {
|
||||||
fileChecker.running = true
|
fileChecker.running = true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
const isLight = (typeof SessionData !== "undefined" && SessionData.isLightMode)
|
||||||
|
const iconTheme = (typeof SettingsData !== "undefined" && SettingsData.iconTheme) ? SettingsData.iconTheme : "System Default"
|
||||||
|
|
||||||
|
if (currentTheme === dynamic) {
|
||||||
|
if (wallpaperPath) {
|
||||||
|
// Clear cache on startup to force regeneration
|
||||||
|
Quickshell.execDetached(["rm", "-f", stateDir + "/matugen.key"])
|
||||||
|
setDesiredTheme("image", wallpaperPath, isLight, iconTheme)
|
||||||
|
} else {
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
let primaryColor
|
||||||
|
if (currentTheme === "custom") {
|
||||||
|
if (customThemeData && customThemeData.primary) {
|
||||||
|
primaryColor = customThemeData.primary
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
primaryColor = currentThemeData.primary
|
||||||
|
}
|
||||||
|
|
||||||
|
if (primaryColor) {
|
||||||
|
// Clear cache on startup to force regeneration
|
||||||
|
Quickshell.execDetached(["rm", "-f", stateDir + "/matugen.key"])
|
||||||
|
setDesiredTheme("hex", primaryColor, isLight, iconTheme)
|
||||||
|
} else {
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -566,7 +578,6 @@ Singleton {
|
|||||||
try {
|
try {
|
||||||
root.matugenColors = JSON.parse(extractedJson)
|
root.matugenColors = JSON.parse(extractedJson)
|
||||||
root.colorUpdateTrigger++
|
root.colorUpdateTrigger++
|
||||||
generateAppConfigs()
|
|
||||||
if (typeof ToastService !== "undefined") {
|
if (typeof ToastService !== "undefined") {
|
||||||
ToastService.clearWallpaperError()
|
ToastService.clearWallpaperError()
|
||||||
}
|
}
|
||||||
@@ -589,32 +600,24 @@ Singleton {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Process {
|
||||||
|
id: ensureStateDir
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
Process {
|
Process {
|
||||||
id: systemThemeGenerator
|
id: systemThemeGenerator
|
||||||
running: false
|
running: false
|
||||||
|
|
||||||
stdout: StdioCollector {
|
|
||||||
id: systemThemeStdout
|
|
||||||
}
|
|
||||||
|
|
||||||
stderr: StdioCollector {
|
|
||||||
id: systemThemeStderr
|
|
||||||
}
|
|
||||||
|
|
||||||
onExited: exitCode => {
|
onExited: exitCode => {
|
||||||
systemThemeGenerationInProgress = false
|
workerRunning = false
|
||||||
|
|
||||||
if (exitCode !== 0) {
|
if (exitCode !== 0) {
|
||||||
if (typeof ToastService !== "undefined") {
|
if (typeof ToastService !== "undefined") {
|
||||||
ToastService.showError("Failed to generate system themes: " + systemThemeStderr.text)
|
ToastService.showError("Theme worker failed (" + exitCode + ")")
|
||||||
}
|
}
|
||||||
console.warn("System theme generation failed with exit code:", exitCode)
|
console.warn("Theme worker failed with exit code:", exitCode)
|
||||||
console.warn("STDOUT:", systemThemeStdout.text)
|
|
||||||
console.warn("STDERR:", systemThemeStderr.text)
|
|
||||||
} else {
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Process next request in queue if any
|
|
||||||
Qt.callLater(processThemeQueue)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -669,13 +672,6 @@ Singleton {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
function generateAppConfigs() {
|
|
||||||
if (!matugenColors || !matugenColors.colors) {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
generateSystemThemes()
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -683,9 +679,6 @@ Singleton {
|
|||||||
matugenCheck.running = true
|
matugenCheck.running = true
|
||||||
if (typeof SessionData !== "undefined")
|
if (typeof SessionData !== "undefined")
|
||||||
SessionData.isLightModeChanged.connect(root.onLightModeChanged)
|
SessionData.isLightModeChanged.connect(root.onLightModeChanged)
|
||||||
|
|
||||||
// Generate system themes on startup for current theme
|
|
||||||
Qt.callLater(generateSystemThemesFromCurrentTheme)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
FileView {
|
FileView {
|
||||||
|
|||||||
@@ -23,19 +23,19 @@ def generate_palette(base_color, is_light=False, honor_primary=None):
|
|||||||
else:
|
else:
|
||||||
palette.append("#1a1a1a")
|
palette.append("#1a1a1a")
|
||||||
|
|
||||||
red_h = 0.0 # Force true red hue (0 degrees)
|
red_h = 0.0
|
||||||
if is_light:
|
if is_light:
|
||||||
palette.append(rgb_to_hex(*colorsys.hsv_to_rgb(red_h, 0.75, 0.85)))
|
palette.append(rgb_to_hex(*colorsys.hsv_to_rgb(red_h, 0.75, 0.85)))
|
||||||
else:
|
else:
|
||||||
palette.append(rgb_to_hex(*colorsys.hsv_to_rgb(red_h, 0.65, 1.0)))
|
palette.append(rgb_to_hex(*colorsys.hsv_to_rgb(red_h, 0.6, 0.8)))
|
||||||
|
|
||||||
green_h = 0.33 # Force true green hue (120 degrees / 360 = 0.33)
|
green_h = 0.33
|
||||||
if is_light:
|
if is_light:
|
||||||
palette.append(rgb_to_hex(*colorsys.hsv_to_rgb(green_h, max(s * 0.8, 0.65), v * 0.9)))
|
palette.append(rgb_to_hex(*colorsys.hsv_to_rgb(green_h, max(s * 0.8, 0.65), v * 0.9)))
|
||||||
else:
|
else:
|
||||||
palette.append(rgb_to_hex(*colorsys.hsv_to_rgb(green_h, max(s * 0.7, 0.6), v * 1.1)))
|
palette.append(rgb_to_hex(*colorsys.hsv_to_rgb(green_h, max(s * 0.65, 0.5), v * 0.9)))
|
||||||
|
|
||||||
yellow_h = 0.16 # Force true yellow hue (60 degrees / 360 = 0.16)
|
yellow_h = 0.16
|
||||||
if is_light:
|
if is_light:
|
||||||
palette.append(rgb_to_hex(*colorsys.hsv_to_rgb(yellow_h, max(s * 0.7, 0.55), v * 1.2)))
|
palette.append(rgb_to_hex(*colorsys.hsv_to_rgb(yellow_h, max(s * 0.7, 0.55), v * 1.2)))
|
||||||
else:
|
else:
|
||||||
@@ -44,17 +44,27 @@ def generate_palette(base_color, is_light=False, honor_primary=None):
|
|||||||
if is_light:
|
if is_light:
|
||||||
palette.append(rgb_to_hex(*colorsys.hsv_to_rgb(h, max(s * 0.9, 0.7), v * 1.1)))
|
palette.append(rgb_to_hex(*colorsys.hsv_to_rgb(h, max(s * 0.9, 0.7), v * 1.1)))
|
||||||
else:
|
else:
|
||||||
palette.append(rgb_to_hex(*colorsys.hsv_to_rgb(h, max(s * 0.7, 0.6), min(v * 1.3, 0.9))))
|
palette.append(rgb_to_hex(*colorsys.hsv_to_rgb(h, max(s * 0.8, 0.6), min(v * 1.6, 1.0))))
|
||||||
|
|
||||||
mag_h = h + 0.15 if h + 0.15 <= 1.0 else h + 0.15 - 1.0 # Derive from primary hue for harmony
|
mag_h = h - 0.03 if h >= 0.03 else h + 0.97
|
||||||
if is_light:
|
if honor_primary:
|
||||||
palette.append(rgb_to_hex(*colorsys.hsv_to_rgb(mag_h, max(s * 0.8, 0.65), v * 0.95)))
|
hr, hg, hb = hex_to_rgb(honor_primary)
|
||||||
|
hh, hs, hv = colorsys.rgb_to_hsv(hr, hg, hb)
|
||||||
|
if is_light:
|
||||||
|
palette.append(rgb_to_hex(*colorsys.hsv_to_rgb(hh, max(hs * 0.9, 0.7), hv * 0.85)))
|
||||||
|
else:
|
||||||
|
palette.append(rgb_to_hex(*colorsys.hsv_to_rgb(hh, hs * 0.8, hv * 0.75)))
|
||||||
|
elif is_light:
|
||||||
|
palette.append(rgb_to_hex(*colorsys.hsv_to_rgb(mag_h, max(s * 0.75, 0.6), v * 0.9)))
|
||||||
else:
|
else:
|
||||||
palette.append(rgb_to_hex(*colorsys.hsv_to_rgb(mag_h, max(s * 0.65, 0.55), min(v * 1.15, 0.8))))
|
palette.append(rgb_to_hex(*colorsys.hsv_to_rgb(mag_h, max(s * 0.7, 0.6), v * 0.85)))
|
||||||
|
|
||||||
cyan_h = h + 0.08
|
cyan_h = h + 0.08
|
||||||
if honor_primary and not is_light:
|
if honor_primary:
|
||||||
palette.append(honor_primary)
|
if is_light:
|
||||||
|
palette.append(honor_primary)
|
||||||
|
else:
|
||||||
|
palette.append(honor_primary)
|
||||||
elif is_light:
|
elif is_light:
|
||||||
palette.append(rgb_to_hex(*colorsys.hsv_to_rgb(cyan_h, max(s * 0.8, 0.65), v * 1.05)))
|
palette.append(rgb_to_hex(*colorsys.hsv_to_rgb(cyan_h, max(s * 0.8, 0.65), v * 1.05)))
|
||||||
else:
|
else:
|
||||||
@@ -71,7 +81,12 @@ def generate_palette(base_color, is_light=False, honor_primary=None):
|
|||||||
palette.append(rgb_to_hex(*colorsys.hsv_to_rgb(red_h, 0.6, 0.9)))
|
palette.append(rgb_to_hex(*colorsys.hsv_to_rgb(red_h, 0.6, 0.9)))
|
||||||
palette.append(rgb_to_hex(*colorsys.hsv_to_rgb(green_h, max(s * 0.7, 0.6), v * 1.25)))
|
palette.append(rgb_to_hex(*colorsys.hsv_to_rgb(green_h, max(s * 0.7, 0.6), v * 1.25)))
|
||||||
palette.append(rgb_to_hex(*colorsys.hsv_to_rgb(yellow_h, max(s * 0.6, 0.5), v * 1.35)))
|
palette.append(rgb_to_hex(*colorsys.hsv_to_rgb(yellow_h, max(s * 0.6, 0.5), v * 1.35)))
|
||||||
palette.append(rgb_to_hex(*colorsys.hsv_to_rgb(h, max(s * 0.8, 0.7), min(v * 1.3, 1.0))))
|
if honor_primary:
|
||||||
|
hr, hg, hb = hex_to_rgb(honor_primary)
|
||||||
|
hh, hs, hv = colorsys.rgb_to_hsv(hr, hg, hb)
|
||||||
|
palette.append(rgb_to_hex(*colorsys.hsv_to_rgb(hh, min(hs * 1.1, 1.0), min(hv * 1.2, 1.0))))
|
||||||
|
else:
|
||||||
|
palette.append(rgb_to_hex(*colorsys.hsv_to_rgb(h, max(s * 0.8, 0.7), min(v * 1.3, 1.0))))
|
||||||
palette.append(rgb_to_hex(*colorsys.hsv_to_rgb(mag_h, max(s * 0.9, 0.75), min(v * 1.25, 1.0))))
|
palette.append(rgb_to_hex(*colorsys.hsv_to_rgb(mag_h, max(s * 0.9, 0.75), min(v * 1.25, 1.0))))
|
||||||
palette.append(rgb_to_hex(*colorsys.hsv_to_rgb(cyan_h, max(s * 0.75, 0.65), min(v * 1.25, 1.0))))
|
palette.append(rgb_to_hex(*colorsys.hsv_to_rgb(cyan_h, max(s * 0.75, 0.65), min(v * 1.25, 1.0))))
|
||||||
else:
|
else:
|
||||||
@@ -84,8 +99,8 @@ def generate_palette(base_color, is_light=False, honor_primary=None):
|
|||||||
palette.append(rgb_to_hex(*colorsys.hsv_to_rgb(hh, min(hs * 1.2, 1.0), min(hv * 1.1, 1.0))))
|
palette.append(rgb_to_hex(*colorsys.hsv_to_rgb(hh, min(hs * 1.2, 1.0), min(hv * 1.1, 1.0))))
|
||||||
else:
|
else:
|
||||||
palette.append(rgb_to_hex(*colorsys.hsv_to_rgb(h, max(s * 0.6, 0.5), min(v * 1.5, 0.9))))
|
palette.append(rgb_to_hex(*colorsys.hsv_to_rgb(h, max(s * 0.6, 0.5), min(v * 1.5, 0.9))))
|
||||||
palette.append(rgb_to_hex(*colorsys.hsv_to_rgb(mag_h, max(s * 0.65, 0.55), min(v * 1.4, 0.85))))
|
palette.append(rgb_to_hex(*colorsys.hsv_to_rgb(mag_h, max(s * 0.7, 0.6), min(v * 1.3, 0.9))))
|
||||||
palette.append(rgb_to_hex(*colorsys.hsv_to_rgb(cyan_h, max(s * 0.55, 0.45), min(v * 1.4, 0.85))))
|
palette.append(rgb_to_hex(*colorsys.hsv_to_rgb(h + 0.02 if h + 0.02 <= 1.0 else h + 0.02 - 1.0, max(s * 0.6, 0.5), min(v * 1.2, 0.85))))
|
||||||
|
|
||||||
if is_light:
|
if is_light:
|
||||||
palette.append("#1a1a1a")
|
palette.append("#1a1a1a")
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
background = {{colors.surface.default.hex}}
|
background = {{colors.surface.default.hex}}
|
||||||
foreground = {{colors.on_surface.default.hex}}
|
foreground = {{colors.on_surface.default.hex}}
|
||||||
cursor-color = {{colors.primary.default.hex}}
|
cursor-color = {{colors.primary.default.hex}}
|
||||||
selection-background = {{colors.surface_container.default.hex}}
|
selection-background = {{colors.primary_container.default.hex}}
|
||||||
selection-foreground = {{colors.on_surface.default.hex}}
|
selection-foreground = {{colors.on_surface.default.hex}}
|
||||||
@@ -105,14 +105,6 @@ dnd {
|
|||||||
color: {{colors.on_surface.default.hex}};
|
color: {{colors.on_surface.default.hex}};
|
||||||
}
|
}
|
||||||
|
|
||||||
.normal-icons {
|
|
||||||
-gtk-icon-size: 16px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.large-icons {
|
|
||||||
-gtk-icon-size: 32px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.background:backdrop {
|
.background:backdrop {
|
||||||
background-color: {{colors.surface_dim.default.hex}};
|
background-color: {{colors.surface_dim.default.hex}};
|
||||||
color: {{colors.on_surface_variant.default.hex}};
|
color: {{colors.on_surface_variant.default.hex}};
|
||||||
|
|||||||
203
scripts/matugen-worker.sh
Executable file
203
scripts/matugen-worker.sh
Executable file
@@ -0,0 +1,203 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
set -euo pipefail
|
||||||
|
|
||||||
|
if [ $# -lt 3 ]; then
|
||||||
|
echo "Usage: $0 STATE_DIR SHELL_DIR --run" >&2
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
STATE_DIR="$1"
|
||||||
|
SHELL_DIR="$2"
|
||||||
|
|
||||||
|
if [ ! -d "$STATE_DIR" ]; then
|
||||||
|
echo "Error: STATE_DIR '$STATE_DIR' does not exist" >&2
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ ! -d "$SHELL_DIR" ]; then
|
||||||
|
echo "Error: SHELL_DIR '$SHELL_DIR' does not exist" >&2
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
shift 2 # Remove STATE_DIR and SHELL_DIR from arguments
|
||||||
|
|
||||||
|
if [[ "${1:-}" != "--run" ]]; then
|
||||||
|
echo "usage: $0 STATE_DIR SHELL_DIR --run" >&2
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
DESIRED_JSON="$STATE_DIR/matugen.desired.json"
|
||||||
|
BUILT_KEY="$STATE_DIR/matugen.key"
|
||||||
|
LAST_JSON="$STATE_DIR/last.json"
|
||||||
|
LOCK="$STATE_DIR/matugen-worker.lock"
|
||||||
|
|
||||||
|
exec 9>"$LOCK"
|
||||||
|
flock 9
|
||||||
|
|
||||||
|
|
||||||
|
read_desired() {
|
||||||
|
[[ ! -f "$DESIRED_JSON" ]] && { echo "no desired state" >&2; exit 0; }
|
||||||
|
cat "$DESIRED_JSON"
|
||||||
|
}
|
||||||
|
|
||||||
|
key_of() {
|
||||||
|
local json="$1"
|
||||||
|
local kind=$(echo "$json" | sed 's/.*"kind": *"\([^"]*\)".*/\1/')
|
||||||
|
local value=$(echo "$json" | sed 's/.*"value": *"\([^"]*\)".*/\1/')
|
||||||
|
local mode=$(echo "$json" | sed 's/.*"mode": *"\([^"]*\)".*/\1/')
|
||||||
|
local icon=$(echo "$json" | sed 's/.*"iconTheme": *"\([^"]*\)".*/\1/')
|
||||||
|
[[ -z "$icon" ]] && icon="System Default"
|
||||||
|
echo "${kind}|${value}|${mode}|${icon}" | sha256sum | cut -d' ' -f1
|
||||||
|
}
|
||||||
|
|
||||||
|
build_once() {
|
||||||
|
local json="$1"
|
||||||
|
local kind value mode icon
|
||||||
|
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/')
|
||||||
|
[[ -z "$icon" ]] && icon="System Default"
|
||||||
|
|
||||||
|
CONFIG_DIR="${CONFIG_DIR:-$HOME/.config}"
|
||||||
|
|
||||||
|
TMP_CFG="$(mktemp)"
|
||||||
|
trap 'rm -f "$TMP_CFG"' RETURN
|
||||||
|
|
||||||
|
cat "$SHELL_DIR/matugen/configs/base.toml" > "$TMP_CFG"
|
||||||
|
echo "" >> "$TMP_CFG"
|
||||||
|
if command -v niri >/dev/null 2>&1; then
|
||||||
|
cat "$SHELL_DIR/matugen/configs/niri.toml" >> "$TMP_CFG"
|
||||||
|
echo "" >> "$TMP_CFG"
|
||||||
|
fi
|
||||||
|
|
||||||
|
if command -v qt5ct >/dev/null 2>&1; then
|
||||||
|
cat "$SHELL_DIR/matugen/configs/qt5ct.toml" >> "$TMP_CFG"
|
||||||
|
echo "" >> "$TMP_CFG"
|
||||||
|
fi
|
||||||
|
|
||||||
|
if command -v qt6ct >/dev/null 2>&1; then
|
||||||
|
cat "$SHELL_DIR/matugen/configs/qt6ct.toml" >> "$TMP_CFG"
|
||||||
|
echo "" >> "$TMP_CFG"
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ "$mode" = "light" ]; then
|
||||||
|
COLLOID_TEMPLATE="$SHELL_DIR/matugen/templates/gtk3-colloid-light.css"
|
||||||
|
else
|
||||||
|
COLLOID_TEMPLATE="$SHELL_DIR/matugen/templates/gtk3-colloid-dark.css"
|
||||||
|
fi
|
||||||
|
|
||||||
|
sed -i "/\[templates\.gtk3\]/,/^$/ s|input_path = './matugen/templates/gtk-colors.css'|input_path = '$COLLOID_TEMPLATE'|" "$TMP_CFG"
|
||||||
|
sed -i "s|input_path = './matugen/templates/|input_path = '$SHELL_DIR/matugen/templates/|g" "$TMP_CFG"
|
||||||
|
|
||||||
|
pushd "$SHELL_DIR" >/dev/null
|
||||||
|
MAT_MODE=(-m "$mode")
|
||||||
|
|
||||||
|
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
|
||||||
|
;;
|
||||||
|
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
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
echo "unknown kind: $kind" >&2; popd >/dev/null; return 2;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
TMP_CONTENT_CFG="$(mktemp)"
|
||||||
|
echo "[config]" > "$TMP_CONTENT_CFG"
|
||||||
|
echo "" >> "$TMP_CONTENT_CFG"
|
||||||
|
|
||||||
|
if command -v ghostty >/dev/null 2>&1; then
|
||||||
|
cat "$SHELL_DIR/matugen/configs/ghostty.toml" >> "$TMP_CONTENT_CFG"
|
||||||
|
sed -i "s|input_path = './matugen/templates/|input_path = '$SHELL_DIR/matugen/templates/|g" "$TMP_CONTENT_CFG"
|
||||||
|
echo "" >> "$TMP_CONTENT_CFG"
|
||||||
|
fi
|
||||||
|
|
||||||
|
if command -v kitty >/dev/null 2>&1; then
|
||||||
|
cat "$SHELL_DIR/matugen/configs/kitty.toml" >> "$TMP_CONTENT_CFG"
|
||||||
|
sed -i "s|input_path = './matugen/templates/|input_path = '$SHELL_DIR/matugen/templates/|g" "$TMP_CONTENT_CFG"
|
||||||
|
echo "" >> "$TMP_CONTENT_CFG"
|
||||||
|
fi
|
||||||
|
|
||||||
|
if command -v dgop >/dev/null 2>&1; then
|
||||||
|
cat "$SHELL_DIR/matugen/configs/dgop.toml" >> "$TMP_CONTENT_CFG"
|
||||||
|
sed -i "s|input_path = './matugen/templates/|input_path = '$SHELL_DIR/matugen/templates/|g" "$TMP_CONTENT_CFG"
|
||||||
|
echo "" >> "$TMP_CONTENT_CFG"
|
||||||
|
fi
|
||||||
|
|
||||||
|
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
|
||||||
|
;;
|
||||||
|
hex)
|
||||||
|
matugen -c "$TMP_CONTENT_CFG" color hex "$value" "${MAT_MODE[@]}" >/dev/null
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
fi
|
||||||
|
|
||||||
|
rm -f "$TMP_CONTENT_CFG"
|
||||||
|
popd >/dev/null
|
||||||
|
|
||||||
|
echo "$JSON" | grep -q '"primary"' || { echo "matugen JSON missing primary" >&2; return 2; }
|
||||||
|
printf "%s" "$JSON" > "$LAST_JSON"
|
||||||
|
|
||||||
|
if [ "$mode" = "light" ]; then
|
||||||
|
SECTION=$(echo "$JSON" | sed -n 's/.*"light":{\([^}]*\)}.*/\1/p')
|
||||||
|
else
|
||||||
|
SECTION=$(echo "$JSON" | sed -n 's/.*"dark":{\([^}]*\)}.*/\1/p')
|
||||||
|
fi
|
||||||
|
|
||||||
|
PRIMARY=$(echo "$SECTION" | sed -n 's/.*"primary_container":"\(#[0-9a-fA-F]\{6\}\)".*/\1/p')
|
||||||
|
HONOR=$(echo "$SECTION" | sed -n 's/.*"primary":"\(#[0-9a-fA-F]\{6\}\)".*/\1/p')
|
||||||
|
|
||||||
|
if command -v ghostty >/dev/null 2>&1 && [[ -f "$CONFIG_DIR/ghostty/config-dankcolors" ]]; then
|
||||||
|
OUT=$("$SHELL_DIR/matugen/b16.py" "$PRIMARY" $([[ "$mode" == "light" ]] && echo --light) ${HONOR:+--honor-primary "$HONOR"} 2>/dev/null || true)
|
||||||
|
if [[ -n "${OUT:-}" ]]; then
|
||||||
|
TMP="$(mktemp)"
|
||||||
|
printf "%s\n\n" "$OUT" > "$TMP"
|
||||||
|
cat "$CONFIG_DIR/ghostty/config-dankcolors" >> "$TMP"
|
||||||
|
mv "$TMP" "$CONFIG_DIR/ghostty/config-dankcolors"
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
if command -v kitty >/dev/null 2>&1 && [[ -f "$CONFIG_DIR/kitty/dank-theme.conf" ]]; then
|
||||||
|
OUT=$("$SHELL_DIR/matugen/b16.py" "$PRIMARY" $([[ "$mode" == "light" ]] && echo --light) ${HONOR:+--honor-primary "$HONOR"} --kitty 2>/dev/null || true)
|
||||||
|
if [[ -n "${OUT:-}" ]]; then
|
||||||
|
TMP="$(mktemp)"
|
||||||
|
printf "%s\n\n" "$OUT" > "$TMP"
|
||||||
|
cat "$CONFIG_DIR/kitty/dank-theme.conf" >> "$TMP"
|
||||||
|
mv "$TMP" "$CONFIG_DIR/kitty/dank-theme.conf"
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
COLOR_SCHEME=$([[ "$mode" == "light" ]] && echo prefer-light || echo prefer-dark)
|
||||||
|
if command -v dconf >/dev/null 2>&1; then
|
||||||
|
dconf write /org/gnome/desktop/interface/color-scheme "\"$COLOR_SCHEME\"" 2>/dev/null || true
|
||||||
|
[[ "$icon" != "System Default" && -n "$icon" ]] && dconf write /org/gnome/desktop/interface/icon-theme "\"$icon\"" 2>/dev/null || true
|
||||||
|
elif command -v gsettings >/dev/null 2>&1; then
|
||||||
|
gsettings set org.gnome.desktop.interface color-scheme "$COLOR_SCHEME" 2>/dev/null || true
|
||||||
|
[[ "$icon" != "System Default" && -n "$icon" ]] && gsettings set org.gnome.desktop.interface icon-theme "$icon" 2>/dev/null || true
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
while :; do
|
||||||
|
DESIRED="$(read_desired)"
|
||||||
|
WANT_KEY="$(key_of "$DESIRED")"
|
||||||
|
HAVE_KEY=""
|
||||||
|
[[ -f "$BUILT_KEY" ]] && HAVE_KEY="$(cat "$BUILT_KEY" 2>/dev/null || true)"
|
||||||
|
|
||||||
|
if [[ "$WANT_KEY" == "$HAVE_KEY" ]]; then
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
|
||||||
|
if build_once "$DESIRED"; then
|
||||||
|
echo "$WANT_KEY" > "$BUILT_KEY"
|
||||||
|
else
|
||||||
|
exit 2
|
||||||
|
fi
|
||||||
|
done
|
||||||
@@ -1,361 +0,0 @@
|
|||||||
#!/usr/bin/env bash
|
|
||||||
|
|
||||||
INPUT_SOURCE="$1"
|
|
||||||
SHELL_DIR="$2"
|
|
||||||
CONFIG_DIR="$3"
|
|
||||||
MODE="$4"
|
|
||||||
IS_LIGHT="$5"
|
|
||||||
ICON_THEME="$6"
|
|
||||||
|
|
||||||
if [ -z "$SHELL_DIR" ] || [ -z "$CONFIG_DIR" ]; then
|
|
||||||
echo "Usage: $0 <input_source> <shell_dir> <config_dir> <mode> [is_light] [icon_theme]" >&2
|
|
||||||
echo " input_source: wallpaper path for 'generate' mode, hex color for 'generate-color' mode" >&2
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
MODE=${MODE:-"generate"}
|
|
||||||
IS_LIGHT=${IS_LIGHT:-"false"}
|
|
||||||
ICON_THEME=${ICON_THEME:-"System Default"}
|
|
||||||
|
|
||||||
update_theme_settings() {
|
|
||||||
local color_scheme="$1"
|
|
||||||
local icon_theme="$2"
|
|
||||||
|
|
||||||
echo "Updating theme settings..."
|
|
||||||
|
|
||||||
if command -v dconf >/dev/null 2>&1; then
|
|
||||||
dconf write /org/gnome/desktop/interface/color-scheme "\"$color_scheme\""
|
|
||||||
echo "Set color-scheme to: $color_scheme"
|
|
||||||
|
|
||||||
if [ "$icon_theme" != "System Default" ] && [ -n "$icon_theme" ]; then
|
|
||||||
dconf write /org/gnome/desktop/interface/icon-theme "\"$icon_theme\""
|
|
||||||
echo "Set icon-theme to: $icon_theme"
|
|
||||||
fi
|
|
||||||
elif command -v gsettings >/dev/null 2>&1; then
|
|
||||||
gsettings set org.gnome.desktop.interface color-scheme "$color_scheme"
|
|
||||||
echo "Set color-scheme to: $color_scheme"
|
|
||||||
|
|
||||||
if [ "$icon_theme" != "System Default" ] && [ -n "$icon_theme" ]; then
|
|
||||||
gsettings set org.gnome.desktop.interface icon-theme "$icon_theme"
|
|
||||||
echo "Set icon-theme to: $icon_theme"
|
|
||||||
fi
|
|
||||||
else
|
|
||||||
echo "Warning: Neither dconf nor gsettings available"
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
build_dynamic_config() {
|
|
||||||
local temp_config="$1"
|
|
||||||
local is_light="$2"
|
|
||||||
local shell_dir="$3"
|
|
||||||
|
|
||||||
echo "Building dynamic matugen configuration..."
|
|
||||||
|
|
||||||
cat "$shell_dir/matugen/configs/base.toml" > "$temp_config"
|
|
||||||
echo "" >> "$temp_config"
|
|
||||||
|
|
||||||
if command -v niri >/dev/null 2>&1; then
|
|
||||||
echo " - Including niri config (niri found)"
|
|
||||||
cat "$shell_dir/matugen/configs/niri.toml" >> "$temp_config"
|
|
||||||
echo "" >> "$temp_config"
|
|
||||||
else
|
|
||||||
echo " - Skipping niri config (niri not found)"
|
|
||||||
fi
|
|
||||||
|
|
||||||
if command -v qt5ct >/dev/null 2>&1; then
|
|
||||||
echo " - Including qt5ct config (qt5ct found)"
|
|
||||||
cat "$shell_dir/matugen/configs/qt5ct.toml" >> "$temp_config"
|
|
||||||
echo "" >> "$temp_config"
|
|
||||||
else
|
|
||||||
echo " - Skipping qt5ct config (qt5ct not found)"
|
|
||||||
fi
|
|
||||||
|
|
||||||
if command -v qt6ct >/dev/null 2>&1; then
|
|
||||||
echo " - Including qt6ct config (qt6ct found)"
|
|
||||||
cat "$shell_dir/matugen/configs/qt6ct.toml" >> "$temp_config"
|
|
||||||
echo "" >> "$temp_config"
|
|
||||||
else
|
|
||||||
echo " - Skipping qt6ct config (qt6ct not found)"
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [ "$is_light" = "true" ]; then
|
|
||||||
COLLOID_TEMPLATE="$shell_dir/matugen/templates/gtk3-colloid-light.css"
|
|
||||||
else
|
|
||||||
COLLOID_TEMPLATE="$shell_dir/matugen/templates/gtk3-colloid-dark.css"
|
|
||||||
fi
|
|
||||||
|
|
||||||
sed -i "/\[templates\.gtk3\]/,/^$/ s|input_path = './matugen/templates/gtk-colors.css'|input_path = '$COLLOID_TEMPLATE'|" "$temp_config"
|
|
||||||
sed -i "s|input_path = './matugen/templates/|input_path = '$shell_dir/matugen/templates/|g" "$temp_config"
|
|
||||||
}
|
|
||||||
|
|
||||||
build_content_config() {
|
|
||||||
local temp_config="$1"
|
|
||||||
local is_light="$2"
|
|
||||||
local shell_dir="$3"
|
|
||||||
|
|
||||||
echo "Building dynamic content configuration..."
|
|
||||||
|
|
||||||
echo "[config]" > "$temp_config"
|
|
||||||
echo "" >> "$temp_config"
|
|
||||||
|
|
||||||
if command -v ghostty >/dev/null 2>&1; then
|
|
||||||
echo " - Including ghostty config (ghostty found)"
|
|
||||||
cat "$shell_dir/matugen/configs/ghostty.toml" >> "$temp_config"
|
|
||||||
sed -i "s|input_path = './matugen/templates/|input_path = '$shell_dir/matugen/templates/|g" "$temp_config"
|
|
||||||
echo "" >> "$temp_config"
|
|
||||||
else
|
|
||||||
echo " - Skipping ghostty config (ghostty not found)"
|
|
||||||
fi
|
|
||||||
|
|
||||||
if command -v kitty >/dev/null 2>&1; then
|
|
||||||
echo " - Including kitty config (kitty found)"
|
|
||||||
cat "$shell_dir/matugen/configs/kitty.toml" >> "$temp_config"
|
|
||||||
sed -i "s|input_path = './matugen/templates/|input_path = '$shell_dir/matugen/templates/|g" "$temp_config"
|
|
||||||
echo "" >> "$temp_config"
|
|
||||||
else
|
|
||||||
echo " - Skipping kitty config (kitty not found)"
|
|
||||||
fi
|
|
||||||
|
|
||||||
if command -v dgop >/dev/null 2>&1; then
|
|
||||||
echo " - Including dgop config (dgop found)"
|
|
||||||
cat "$shell_dir/matugen/configs/dgop.toml" >> "$temp_config"
|
|
||||||
sed -i "s|input_path = './matugen/templates/|input_path = '$shell_dir/matugen/templates/|g" "$temp_config"
|
|
||||||
echo "" >> "$temp_config"
|
|
||||||
else
|
|
||||||
echo " - Skipping dgop config (dgop not found)"
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
if [ "$MODE" = "generate" ]; then
|
|
||||||
if [ ! -f "$INPUT_SOURCE" ]; then
|
|
||||||
echo "Wallpaper file not found: $INPUT_SOURCE" >&2
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
elif [ "$MODE" = "generate-color" ]; then
|
|
||||||
if ! echo "$INPUT_SOURCE" | grep -qE '^#[0-9A-Fa-f]{6}$'; then
|
|
||||||
echo "Invalid hex color format: $INPUT_SOURCE (expected format: #RRGGBB)" >&2
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [ ! -d "$SHELL_DIR" ]; then
|
|
||||||
echo "Shell directory not found: $SHELL_DIR" >&2
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
cd "$SHELL_DIR" || exit 1
|
|
||||||
|
|
||||||
if [ ! -d "matugen/configs" ]; then
|
|
||||||
echo "Config directory not found: $SHELL_DIR/matugen/configs" >&2
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
TEMP_CONFIG="/tmp/matugen-config-$$.toml"
|
|
||||||
build_dynamic_config "$TEMP_CONFIG" "$IS_LIGHT" "$SHELL_DIR"
|
|
||||||
|
|
||||||
MATUGEN_MODE=""
|
|
||||||
if [ "$IS_LIGHT" = "true" ]; then
|
|
||||||
MATUGEN_MODE="-m light"
|
|
||||||
else
|
|
||||||
MATUGEN_MODE="-m dark"
|
|
||||||
fi
|
|
||||||
|
|
||||||
EXTRACTED_PRIMARY=""
|
|
||||||
|
|
||||||
if [ "$MODE" = "generate" ]; then
|
|
||||||
echo "Generating matugen themes from wallpaper: $INPUT_SOURCE"
|
|
||||||
echo "Using dynamic config: $TEMP_CONFIG"
|
|
||||||
|
|
||||||
# Generate templates (no JSON needed for main themes)
|
|
||||||
if ! matugen -c "$TEMP_CONFIG" image "$INPUT_SOURCE" $MATUGEN_MODE; then
|
|
||||||
echo "Failed to generate themes with matugen" >&2
|
|
||||||
rm -f "$TEMP_CONFIG"
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
elif [ "$MODE" = "generate-color" ]; then
|
|
||||||
echo "Generating matugen themes from color: $INPUT_SOURCE"
|
|
||||||
echo "Using dynamic config: $TEMP_CONFIG"
|
|
||||||
|
|
||||||
# Generate templates, for color mode we already have the primary
|
|
||||||
if ! matugen -c "$TEMP_CONFIG" color hex "$INPUT_SOURCE" $MATUGEN_MODE; then
|
|
||||||
echo "Failed to generate themes with matugen" >&2
|
|
||||||
rm -f "$TEMP_CONFIG"
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
# For color mode, we already have the input color as primary
|
|
||||||
EXTRACTED_PRIMARY="$INPUT_SOURCE"
|
|
||||||
fi
|
|
||||||
|
|
||||||
TEMP_CONTENT_CONFIG="/tmp/matugen-content-config-$$.toml"
|
|
||||||
build_content_config "$TEMP_CONTENT_CONFIG" "$IS_LIGHT" "$SHELL_DIR"
|
|
||||||
|
|
||||||
if [ -s "$TEMP_CONTENT_CONFIG" ] && grep -q '\[templates\.' "$TEMP_CONTENT_CONFIG"; then
|
|
||||||
echo "Running content-specific theme generation..."
|
|
||||||
# Generate content-specific templates
|
|
||||||
if [ "$MODE" = "generate" ]; then
|
|
||||||
matugen -c "$TEMP_CONTENT_CONFIG" -t scheme-content image "$INPUT_SOURCE" $MATUGEN_MODE
|
|
||||||
elif [ "$MODE" = "generate-color" ]; then
|
|
||||||
matugen -c "$TEMP_CONTENT_CONFIG" -t scheme-content color hex "$INPUT_SOURCE" $MATUGEN_MODE
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Small delay to ensure content generation completes
|
|
||||||
sleep 0.1
|
|
||||||
|
|
||||||
# Get JSON with error handling
|
|
||||||
if [ "$MODE" = "generate" ]; then
|
|
||||||
if ! DEFAULT_JSON=$(matugen --json hex image "$INPUT_SOURCE" $MATUGEN_MODE 2>&1); then
|
|
||||||
echo "Warning: Failed to get JSON from matugen for image mode"
|
|
||||||
DEFAULT_JSON=""
|
|
||||||
fi
|
|
||||||
elif [ "$MODE" = "generate-color" ]; then
|
|
||||||
if ! DEFAULT_JSON=$(matugen --json hex color hex "$INPUT_SOURCE" $MATUGEN_MODE 2>&1); then
|
|
||||||
echo "Warning: Failed to get JSON from matugen for color mode"
|
|
||||||
DEFAULT_JSON=""
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Extract primary_container for b16 base color and primary for honoring
|
|
||||||
if [ -n "$DEFAULT_JSON" ] && echo "$DEFAULT_JSON" | grep -q '"primary_container"'; then
|
|
||||||
EXTRACTED_PRIMARY=$(echo "$DEFAULT_JSON" | grep -oE '"primary_container":"#[0-9a-fA-F]{6}"' | sed -n '1p' | cut -d'"' -f4)
|
|
||||||
echo "Successfully extracted primary_container: $EXTRACTED_PRIMARY"
|
|
||||||
|
|
||||||
# Also extract the actual primary color to honor in palette
|
|
||||||
if [ "$IS_LIGHT" = "true" ]; then
|
|
||||||
# Light mode: get primary from light theme (second occurrence)
|
|
||||||
HONOR_PRIMARY=$(echo "$DEFAULT_JSON" | grep -oE '"primary":"#[0-9a-fA-F]{6}"' | sed -n '2p' | cut -d'"' -f4)
|
|
||||||
else
|
|
||||||
# Dark mode: get primary from dark theme (first occurrence)
|
|
||||||
HONOR_PRIMARY=$(echo "$DEFAULT_JSON" | grep -oE '"primary":"#[0-9a-fA-F]{6}"' | sed -n '1p' | cut -d'"' -f4)
|
|
||||||
fi
|
|
||||||
echo "Successfully extracted primary for honoring: $HONOR_PRIMARY"
|
|
||||||
else
|
|
||||||
echo "Warning: No primary_container found in JSON output"
|
|
||||||
EXTRACTED_PRIMARY=""
|
|
||||||
HONOR_PRIMARY=""
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Fallback if extraction failed
|
|
||||||
if [ -z "$EXTRACTED_PRIMARY" ]; then
|
|
||||||
if [ "$MODE" = "generate-color" ]; then
|
|
||||||
EXTRACTED_PRIMARY="$INPUT_SOURCE"
|
|
||||||
HONOR_PRIMARY="$INPUT_SOURCE"
|
|
||||||
echo "Using input color as primary: $EXTRACTED_PRIMARY"
|
|
||||||
else
|
|
||||||
EXTRACTED_PRIMARY="#6b5f8e"
|
|
||||||
HONOR_PRIMARY="#ccbeff" # Default Material Design primary for fallback
|
|
||||||
echo "Warning: Could not extract primary color, using fallback: $EXTRACTED_PRIMARY"
|
|
||||||
fi
|
|
||||||
else
|
|
||||||
echo "Extracted primary color from scheme-content: $EXTRACTED_PRIMARY"
|
|
||||||
fi
|
|
||||||
|
|
||||||
if command -v ghostty >/dev/null 2>&1; then
|
|
||||||
echo "Generating base16 palette for ghostty..."
|
|
||||||
|
|
||||||
PRIMARY_COLOR="$EXTRACTED_PRIMARY"
|
|
||||||
if [ -z "$PRIMARY_COLOR" ]; then
|
|
||||||
if [ "$MODE" = "generate-color" ]; then
|
|
||||||
PRIMARY_COLOR="$INPUT_SOURCE"
|
|
||||||
echo "Using input color as primary: $PRIMARY_COLOR"
|
|
||||||
else
|
|
||||||
PRIMARY_COLOR="#6b5f8e"
|
|
||||||
echo "Warning: Could not extract primary color, using fallback: $PRIMARY_COLOR"
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
|
|
||||||
B16_ARGS="$PRIMARY_COLOR"
|
|
||||||
if [ "$IS_LIGHT" = "true" ]; then
|
|
||||||
B16_ARGS="$B16_ARGS --light"
|
|
||||||
fi
|
|
||||||
if [ -n "$HONOR_PRIMARY" ]; then
|
|
||||||
B16_ARGS="$B16_ARGS --honor-primary $HONOR_PRIMARY"
|
|
||||||
fi
|
|
||||||
|
|
||||||
B16_OUTPUT=$("$SHELL_DIR/matugen/b16.py" $B16_ARGS)
|
|
||||||
|
|
||||||
if [ $? -eq 0 ] && [ -n "$B16_OUTPUT" ]; then
|
|
||||||
TEMP_GHOSTTY="/tmp/ghostty-config-$$.conf"
|
|
||||||
echo "$B16_OUTPUT" > "$TEMP_GHOSTTY"
|
|
||||||
echo "" >> "$TEMP_GHOSTTY"
|
|
||||||
|
|
||||||
if [ -f "$CONFIG_DIR/ghostty/config-dankcolors" ]; then
|
|
||||||
cat "$CONFIG_DIR/ghostty/config-dankcolors" >> "$TEMP_GHOSTTY"
|
|
||||||
mv "$TEMP_GHOSTTY" "$CONFIG_DIR/ghostty/config-dankcolors"
|
|
||||||
echo "Base16 palette prepended to ghostty config"
|
|
||||||
else
|
|
||||||
echo "Warning: $CONFIG_DIR/ghostty/config-dankcolors not found, skipping b16 prepend"
|
|
||||||
rm -f "$TEMP_GHOSTTY"
|
|
||||||
fi
|
|
||||||
else
|
|
||||||
echo "Warning: Failed to generate base16 palette"
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
|
|
||||||
if command -v kitty >/dev/null 2>&1; then
|
|
||||||
echo "Generating base16 palette for kitty..."
|
|
||||||
|
|
||||||
PRIMARY_COLOR="$EXTRACTED_PRIMARY"
|
|
||||||
if [ -z "$PRIMARY_COLOR" ]; then
|
|
||||||
if [ "$MODE" = "generate-color" ]; then
|
|
||||||
PRIMARY_COLOR="$INPUT_SOURCE"
|
|
||||||
echo "Using input color as primary: $PRIMARY_COLOR"
|
|
||||||
else
|
|
||||||
PRIMARY_COLOR="#6b5f8e"
|
|
||||||
echo "Warning: Could not extract primary color, using fallback: $PRIMARY_COLOR"
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
|
|
||||||
B16_ARGS="$PRIMARY_COLOR"
|
|
||||||
if [ "$IS_LIGHT" = "true" ]; then
|
|
||||||
B16_ARGS="$B16_ARGS --light"
|
|
||||||
fi
|
|
||||||
if [ -n "$HONOR_PRIMARY" ]; then
|
|
||||||
B16_ARGS="$B16_ARGS --honor-primary $HONOR_PRIMARY"
|
|
||||||
fi
|
|
||||||
|
|
||||||
B16_OUTPUT=$("$SHELL_DIR/matugen/b16.py" $B16_ARGS --kitty)
|
|
||||||
|
|
||||||
if [ $? -eq 0 ] && [ -n "$B16_OUTPUT" ]; then
|
|
||||||
TEMP_KITTY="/tmp/kitty-config-$$.conf"
|
|
||||||
echo "$B16_OUTPUT" > "$TEMP_KITTY"
|
|
||||||
echo "" >> "$TEMP_KITTY"
|
|
||||||
|
|
||||||
if [ -f "$CONFIG_DIR/kitty/dank-theme.conf" ]; then
|
|
||||||
cat "$CONFIG_DIR/kitty/dank-theme.conf" >> "$TEMP_KITTY"
|
|
||||||
mv "$TEMP_KITTY" "$CONFIG_DIR/kitty/dank-theme.conf"
|
|
||||||
echo "Base16 palette prepended to kitty config"
|
|
||||||
else
|
|
||||||
echo "Warning: $CONFIG_DIR/kitty/dank-theme.conf not found, skipping b16 prepend"
|
|
||||||
rm -f "$TEMP_KITTY"
|
|
||||||
fi
|
|
||||||
else
|
|
||||||
echo "Warning: Failed to generate base16 palette for kitty"
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
else
|
|
||||||
echo "No content-specific tools found, skipping content generation"
|
|
||||||
fi
|
|
||||||
|
|
||||||
rm -f "$TEMP_CONFIG" "$TEMP_CONTENT_CONFIG"
|
|
||||||
|
|
||||||
echo "Updating system theme preferences..."
|
|
||||||
|
|
||||||
color_scheme=""
|
|
||||||
if [ "$IS_LIGHT" = "true" ]; then
|
|
||||||
color_scheme="prefer-light"
|
|
||||||
else
|
|
||||||
color_scheme="prefer-dark"
|
|
||||||
fi
|
|
||||||
|
|
||||||
update_theme_settings "$color_scheme" "$ICON_THEME"
|
|
||||||
|
|
||||||
echo "Matugen theme generation completed successfully"
|
|
||||||
echo "Generated configs for detected tools:"
|
|
||||||
[ -f "$CONFIG_DIR/gtk-3.0/dank-colors.css" ] && echo " - GTK 3/4 themes"
|
|
||||||
[ -f "$(eval echo ~/.local/share/color-schemes/DankMatugen.colors)" ] && echo " - KDE color scheme"
|
|
||||||
command -v niri >/dev/null 2>&1 && [ -f "$CONFIG_DIR/niri/dankshell-colors.kdl" ] && echo " - Niri compositor"
|
|
||||||
command -v qt5ct >/dev/null 2>&1 && [ -f "$CONFIG_DIR/qt5ct/colors/matugen.conf" ] && echo " - Qt5ct themes"
|
|
||||||
command -v qt6ct >/dev/null 2>&1 && [ -f "$CONFIG_DIR/qt6ct/colors/matugen.conf" ] && echo " - Qt6ct themes"
|
|
||||||
command -v ghostty >/dev/null 2>&1 && [ -f "$CONFIG_DIR/ghostty/config-dankcolors" ] && echo " - Ghostty terminal"
|
|
||||||
command -v kitty >/dev/null 2>&1 && [ -f "$CONFIG_DIR/kitty/dank-theme.conf" ] && echo " - Kitty terminal"
|
|
||||||
command -v dgop >/dev/null 2>&1 && [ -f "$CONFIG_DIR/dgop/colors.json" ] && echo " - Dgop colors"
|
|
||||||
Reference in New Issue
Block a user