mirror of
https://github.com/zoriya/noctalia-shell.git
synced 2026-08-09 07:48:58 +00:00
203 lines
6.5 KiB
QML
203 lines
6.5 KiB
QML
pragma Singleton
|
|
|
|
import QtQuick
|
|
import Quickshell
|
|
import qs.Commons
|
|
|
|
// Central place to define which templates we generate and where they write.
|
|
// Users can extend it by dropping additional templates into:
|
|
// - Assets/MatugenTemplates/ (built-in templates)
|
|
// - ~/.config/matugen/ (user-defined templates when enableUserTemplates is true)
|
|
// User templates are automatically executed after the main matugen command
|
|
// if enableUserTemplates is enabled in settings.
|
|
Singleton {
|
|
id: root
|
|
|
|
// Build the base TOML using current settings
|
|
function buildConfigToml() {
|
|
var lines = []
|
|
var mode = Settings.data.colorSchemes.darkMode ? "dark" : "light"
|
|
|
|
if (Settings.data.colorSchemes.useWallpaperColors) {
|
|
addWallpaperBasedTemplates(lines, mode)
|
|
}
|
|
|
|
addApplicationTemplates(lines, mode)
|
|
|
|
if (lines.length > 0) {
|
|
const config = ["[config]"].concat(lines)
|
|
return config.join("\n") + "\n"
|
|
}
|
|
|
|
return ""
|
|
}
|
|
|
|
// --------------------------------
|
|
function addWallpaperBasedTemplates(lines, mode) {
|
|
// Noctalia colors
|
|
lines.push("[templates.noctalia]")
|
|
lines.push('input_path = "' + Quickshell.shellDir + '/Assets/MatugenTemplates/noctalia.json"')
|
|
lines.push('output_path = "' + Settings.configDir + 'colors.json"')
|
|
|
|
// Terminal templates (only for wallpaper-based colors)
|
|
addTerminalTemplates(lines)
|
|
}
|
|
|
|
// --------------------------------
|
|
function addTerminalTemplates(lines) {
|
|
var terminals = [{
|
|
"name": "foot",
|
|
"path": "Terminal/foot",
|
|
"output": "~/.config/foot/themes/noctalia"
|
|
}, {
|
|
"name": "ghostty",
|
|
"path": "Terminal/ghostty",
|
|
"output": "~/.config/ghostty/themes/noctalia"
|
|
}, {
|
|
"name": "kitty",
|
|
"path": "Terminal/kitty.conf",
|
|
"output": "~/.config/kitty/themes/noctalia.conf"
|
|
}]
|
|
|
|
terminals.forEach(function (terminal) {
|
|
if (Settings.data.templates[terminal.name]) {
|
|
lines.push("\n[templates." + terminal.name + "]")
|
|
lines.push('input_path = "' + Quickshell.shellDir + '/Assets/MatugenTemplates/' + terminal.path + '"')
|
|
lines.push('output_path = "' + terminal.output + '"')
|
|
lines.push('post_hook = "' + AppThemeService.colorsApplyScript + " " + terminal.name + '"')
|
|
}
|
|
})
|
|
}
|
|
|
|
// Applications configuration
|
|
readonly property var applications: [{
|
|
"name": "gtk",
|
|
"templates": [{
|
|
"version": "gtk3",
|
|
"output": "~/.config/gtk-3.0/gtk.css"
|
|
}, {
|
|
"version": "gtk4",
|
|
"output": "~/.config/gtk-4.0/gtk.css"
|
|
}],
|
|
"input": "gtk.css",
|
|
"postHook": "gsettings set org.gnome.desktop.interface color-scheme prefer-{mode}"
|
|
}, {
|
|
"name": "qt",
|
|
"templates": [{
|
|
"version": "qt5",
|
|
"output": "~/.config/qt5ct/colors/noctalia.conf"
|
|
}, {
|
|
"version": "qt6",
|
|
"output": "~/.config/qt6ct/colors/noctalia.conf"
|
|
}],
|
|
"input": "qtct.conf"
|
|
}, {
|
|
"name": "kcolorscheme",
|
|
"templates": [{
|
|
"version": "kcolorscheme",
|
|
"output": "~/.local/share/color-schemes/noctalia.colors"
|
|
}],
|
|
"input": "kcolorscheme.colors"
|
|
}, {
|
|
"name": "fuzzel",
|
|
"templates": [{
|
|
"version": "fuzzel",
|
|
"output": "~/.config/fuzzel/themes/noctalia"
|
|
}],
|
|
"input": "fuzzel.conf",
|
|
"postHook": AppThemeService.colorsApplyScript + " fuzzel"
|
|
}, {
|
|
"name": "pywalfox",
|
|
"templates": [{
|
|
"version": "pywalfox",
|
|
"output": "~/.cache/wal/colors.json"
|
|
}],
|
|
"input": "pywalfox.json",
|
|
"postHook": AppThemeService.colorsApplyScript + " pywalfox"
|
|
}, {
|
|
"name": "discord_vesktop",
|
|
"templates": [{
|
|
"version": "discord_vesktop",
|
|
"output": "~/.config/vesktop/themes/noctalia.theme.css"
|
|
}],
|
|
"input": "vesktop.css"
|
|
}, {
|
|
"name": "discord_webcord",
|
|
"templates": [{
|
|
"version": "discord_webcord",
|
|
"output": "~/.config/webcord/themes/noctalia.theme.css"
|
|
}],
|
|
"input": "vesktop.css"
|
|
}, {
|
|
"name": "discord_armcord",
|
|
"templates": [{
|
|
"version": "discord_armcord",
|
|
"output": "~/.config/armcord/themes/noctalia.theme.css"
|
|
}],
|
|
"input": "vesktop.css"
|
|
}, {
|
|
"name": "discord_equibop",
|
|
"templates": [{
|
|
"version": "discord_equibop",
|
|
"output": "~/.config/equibop/themes/noctalia.theme.css"
|
|
}],
|
|
"input": "vesktop.css"
|
|
}, {
|
|
"name": "discord_lightcord",
|
|
"templates": [{
|
|
"version": "discord_lightcord",
|
|
"output": "~/.config/lightcord/themes/noctalia.theme.css"
|
|
}],
|
|
"input": "vesktop.css"
|
|
}, {
|
|
"name": "discord_dorion",
|
|
"templates": [{
|
|
"version": "discord_dorion",
|
|
"output": "~/.config/dorion/themes/noctalia.theme.css"
|
|
}],
|
|
"input": "vesktop.css"
|
|
}]
|
|
|
|
// --------------------------------
|
|
function addApplicationTemplates(lines, mode) {
|
|
applications.forEach(function (app) {
|
|
// Check if app has a condition and if it's met
|
|
var shouldInclude = true
|
|
if (app.condition !== undefined) {
|
|
shouldInclude = app.condition
|
|
}
|
|
|
|
if (Settings.data.templates[app.name] && shouldInclude) {
|
|
app.templates.forEach(function (template) {
|
|
lines.push("\n[templates." + template.version + "]")
|
|
lines.push('input_path = "' + Quickshell.shellDir + '/Assets/MatugenTemplates/' + app.input + '"')
|
|
lines.push('output_path = "' + template.output + '"')
|
|
if (app.postHook) {
|
|
var postHook = app.postHook.replace("{mode}", mode)
|
|
lines.push('post_hook = "' + postHook + '"')
|
|
}
|
|
})
|
|
}
|
|
})
|
|
}
|
|
|
|
// Extract Discord clients from applications array
|
|
readonly property var discordClients: {
|
|
var clients = []
|
|
for (var i = 0; i < applications.length; i++) {
|
|
var app = applications[i]
|
|
if (app.name && app.name.startsWith("discord_")) {
|
|
var clientName = app.name.replace("discord_", "")
|
|
var themePath = app.templates[0].output
|
|
var configPath = themePath.replace("/themes/noctalia.theme.css", "")
|
|
clients.push({
|
|
"name": clientName,
|
|
"configPath": configPath,
|
|
"themePath": themePath
|
|
})
|
|
}
|
|
}
|
|
return clients
|
|
}
|
|
}
|