TemplateRegistry: make the user-templates.toml generation more robust

This commit is contained in:
Ly-sec
2025-11-09 19:27:23 +01:00
parent 8c4eff75fd
commit 06566fbd04
+6 -2
View File
@@ -206,12 +206,16 @@ Singleton {
function doWriteUserTemplatesToml() {
var userConfigPath = Settings.configDir + "user-templates.toml"
var configContent = buildUserTemplatesToml()
var userConfigPathEsc = userConfigPath.replace(/'/g, "'\\''")
// Ensure directory exists (should already exist but just in case)
Quickshell.execDetached(["mkdir", "-p", Settings.configDir])
// Write the config file
Quickshell.execDetached(["sh", "-c", `echo '${configContent.replace(/'/g, "'\\''")}' > '${userConfigPath}'`])
// Write the config file using heredoc to avoid escaping issues
var script = `cat > '${userConfigPathEsc}' << 'EOF'\n`
script += configContent
script += "EOF\n"
Quickshell.execDetached(["sh", "-c", script])
Logger.d("TemplateRegistry", "User templates config written to:", userConfigPath)
}