This commit is contained in:
Ly-sec
2025-12-16 20:10:50 +01:00
2 changed files with 55 additions and 17 deletions
@@ -812,7 +812,7 @@ ColumnLayout {
var clientName = client.name === "code" ? "VSCode" : "VSCodium";
clientInfo.push(clientName);
}
return "Detected: " + clientInfo.join(", ");
return "Applied to default profile. Detected: " + clientInfo.join(", ");
}
}
Layout.fillWidth: true
@@ -823,6 +823,18 @@ ColumnLayout {
// Set unified code property
Settings.data.templates.code = checked;
if (ProgramCheckerService.availableCodeClients.length > 0) {
if (!checked) {
const homeDir = Quickshell.env("HOME");
for (var i = 0; i < ProgramCheckerService.availableCodeClients.length; i++) {
var client = ProgramCheckerService.availableCodeClients[i];
var configDir = client.name === "code" ? "Code" : "VSCodium";
var settingsPath = `${homeDir}/.config/${configDir}/User/settings.json`;
// Reset to Visual Studio Dark before uninstalling
Quickshell.execDetached(["sh", "-c", `sed -i 's/"workbench.colorTheme":[[:space:]]*"[^"]*"/"workbench.colorTheme": "Visual Studio Dark"/' "${settingsPath}"`]);
Quickshell.execDetached([client.name, "--uninstall-extension", "undefined_publisher.noctaliatheme"]);
}
}
AppThemeService.generate();
}
}
+42 -16
View File
@@ -118,20 +118,23 @@ Singleton {
} else if (app.id === "code") {
// Handle Code clients specially
if (Settings.data.templates.code) {
const homeDir = Quickshell.env("HOME");
app.clients.forEach(client => {
// Check if this specific client is detected
if (isCodeClientEnabled(client.name)) {
lines.push(`\n[templates.code_${client.name}]`);
lines.push(`input_path = "${Quickshell.shellDir}/Assets/MatugenTemplates/${app.input}"`);
lines.push(`output_path = "${client.path}"`);
const expandedPath = client.path.replace("~", homeDir);
lines.push(`output_path = "${expandedPath}"`);
var configDir = client.name === "code" ? "Code" : "VSCodium";
var settingsPath = `~/.config/${configDir}/User/settings.json`;
// install the vsix theme file only if grep returns null
var installVsix = `${client.name} --list-extensions | grep -q noctaliatheme || ${client.name} --install-extension '${Quickshell.shellDir}/Assets/MatugenTemplates/noctaliatheme-0.0.1.vsix'`;
// update the settings.json file to use the Noctalia theme
var updateSettingsJson = `if [ -f ${settingsPath} ]; then sed -i '/\\\"workbench.colorTheme\\\":/d' ${settingsPath} && sed -i '1,/{/s/{/{\\\\n \\\"workbench.colorTheme\\\": \\\"NoctaliaTheme\\\",/' ${settingsPath}; fi`;
// do things :3
lines.push(`post_hook = "sh -c \\"${installVsix}; ${updateSettingsJson}\\""`);
var settingsPath = `${homeDir}/.config/${configDir}/User/settings.json`;
// Uninstall/reinstall with modified vsix to force theme reload
var tmpDir = `/tmp/noctalia-vscode-${client.name}`;
var modifiedVsix = `${tmpDir}/noctaliatheme.vsix`;
var reinstallVsix = `if command -v ${client.name} >/dev/null 2>&1; then ${client.name} --uninstall-extension undefined_publisher.noctaliatheme 2>&1; rm -rf ${tmpDir} && mkdir -p ${tmpDir} && unzip -q '${Quickshell.shellDir}/Assets/MatugenTemplates/noctaliatheme-0.0.1.vsix' -d ${tmpDir} && cp '${expandedPath}' ${tmpDir}/extension/themes/NoctaliaTheme-color-theme.json && cd ${tmpDir} && zip -q -r ${modifiedVsix} . && ${client.name} --install-extension ${modifiedVsix} 2>&1 && rm -rf ${tmpDir}; fi`;
var updateSettingsJson = `if command -v ${client.name} >/dev/null 2>&1 && [ -f ${settingsPath} ]; then sed -i 's/\\\\\\"workbench.colorTheme\\\\\\":[[:space:]]*\\\\\\"[^\\\\\\"]*/\\\\\\"workbench.colorTheme\\\\\\": \\\\\\"NoctaliaTheme/' ${settingsPath}; fi`;
lines.push(`post_hook = "sh -c \\"${reinstallVsix}; ${updateSettingsJson}\\""`);
}
});
}
@@ -271,14 +274,37 @@ Singleton {
baseConfigDir = "~/.vscode-oss".replace("~", homeDir);
}
script += `\n`;
script += `if [ -d "${baseConfigDir}" ]; then\n`;
script += ` mkdir -p ${outputDir}\n`;
script += ` cp '${templatePath}' '${outputPath}'\n`;
script += ` ${replaceColorsInFile(outputPath, palette)}`;
script += `else\n`;
script += ` echo "Code client ${client.name} not found at ${baseConfigDir}, skipping"\n`;
script += `fi\n`;
var configDir = client.name === "code" ? "Code" : "VSCodium";
var settingsPath = `${homeDir}/.config/${configDir}/User/settings.json`;
// Uninstall, modify vsix, then reinstall - forces VSCode to reload with updated colors
var tmpDir = `/tmp/noctalia-vscode-${client.name}`;
var tmpTheme = `${tmpDir}/theme.json`;
var modifiedVsix = `${tmpDir}/noctaliatheme.vsix`;
// Generate theme, uninstall, modify vsix, reinstall
script += `
if [ -d "${baseConfigDir}" ]; then
if command -v ${client.name} >/dev/null 2>&1; then
rm -rf ${tmpDir} && mkdir -p ${tmpDir}
cp '${templatePath}' '${tmpTheme}'
${replaceColorsInFile(tmpTheme, palette)}
${client.name} --uninstall-extension undefined_publisher.noctaliatheme 2>&1
unzip -q '${Quickshell.shellDir}/Assets/MatugenTemplates/noctaliatheme-0.0.1.vsix' -d ${tmpDir}
cp '${tmpTheme}' ${tmpDir}/extension/themes/NoctaliaTheme-color-theme.json
cd ${tmpDir} && zip -q -r ${modifiedVsix} .
${client.name} --install-extension ${modifiedVsix} 2>&1
rm -rf ${tmpDir}
if [ -f "${settingsPath}" ]; then
sed -i 's/\\"workbench.colorTheme\\":[[:space:]]*\\"[^\\"]*/\\"workbench.colorTheme\\": \\"NoctaliaTheme/' "${settingsPath}"
fi
fi
else
echo "Code client ${client.name} not found at ${baseConfigDir}, skipping"
fi
`;
});
return script;