Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 25 additions & 0 deletions src/components/SettingsSidebar.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ export const SettingsSidebar = GObject.registerClass(
this._includeNeovim = true;
this._includeVencord = false;
this._includeZed = false;
this._includeVscode = false;
this._includeGtk = false;
this._lightMode = false;
this._selectedNeovimConfig = null;
Expand Down Expand Up @@ -638,6 +639,27 @@ export const SettingsSidebar = GObject.registerClass(

expanderRow.add_row(zedRow);

const vscodeRow = new Adw.ActionRow({
title: 'Include VSCode Theme',
subtitle:
'Copy vscode.json to ~/.vscode/extensions/theme-aether/themes/',
});

this._vscodeSwitch = new Gtk.Switch({
active: this._includeVscode,
valign: Gtk.Align.CENTER,
});

this._vscodeSwitch.connect('notify::active', sw => {
this._includeVscode = sw.get_active();
this.emit('settings-changed', this.getSettings());
});

vscodeRow.add_suffix(this._vscodeSwitch);
vscodeRow.set_activatable_widget(this._vscodeSwitch);

expanderRow.add_row(vscodeRow);

return expanderRow;
}

Expand Down Expand Up @@ -790,6 +812,7 @@ export const SettingsSidebar = GObject.registerClass(
includeNeovim: this._includeNeovim,
includeVencord: this._includeVencord,
includeZed: this._includeZed,
includeVscode: this._includeVscode,
includeGtk: this._includeGtk,
lightMode: this._lightMode,
selectedNeovimConfig: this._selectedNeovimConfig,
Expand All @@ -809,6 +832,7 @@ export const SettingsSidebar = GObject.registerClass(
this._includeNeovim = settings.includeNeovim ?? true;
this._includeVencord = settings.includeVencord ?? false;
this._includeZed = settings.includeZed ?? false;
this._includeVscode = settings.includeVscode ?? false;
this._includeGtk = settings.includeGtk ?? false;
this._enableAppOverrides = settings.enableAppOverrides ?? false;
console.log('Loaded settings from', this._settingsPath);
Expand All @@ -826,6 +850,7 @@ export const SettingsSidebar = GObject.registerClass(
includeNeovim: this._includeNeovim,
includeVencord: this._includeVencord,
includeZed: this._includeZed,
includeVscode: this._includeVscode,
includeGtk: this._includeGtk,
enableAppOverrides: this._enableAppOverrides,
};
Expand Down
112 changes: 109 additions & 3 deletions src/utils/ConfigWriter.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ export class ConfigWriter {
this._copyWallpaper(wallpaperPath);
}

const variables = this._buildVariables(colorRoles);
const variables = this._buildVariables(colorRoles, lightMode);
this._processTemplates(variables, settings, appOverrides);
this._applyAetherThemeOverride(variables);

Expand All @@ -77,6 +77,11 @@ export class ConfigWriter {
this._copyZedTheme();
}

// Copy VSCode theme if enabled
if (settings.includeVscode === true) {
this._copyVscodeTheme(variables);
}

this._handleLightModeMarker(this.themeDir, lightMode);
this._applyOmarchyTheme();

Expand Down Expand Up @@ -107,14 +112,17 @@ export class ConfigWriter {
return destPath;
}

_buildVariables(colorRoles) {
_buildVariables(colorRoles, lightMode = false) {
const variables = {};

// Use default colors as fallback
Object.keys(DEFAULT_COLORS).forEach(key => {
variables[key] = colorRoles[key] || DEFAULT_COLORS[key];
});

// Add theme type for VSCode and other templates
variables.theme_type = lightMode ? 'light' : 'dark';

return variables;
}

Expand Down Expand Up @@ -156,6 +164,25 @@ export class ConfigWriter {
fileName,
]);

// Handle vscode.empty.json - use when VSCode is disabled
if (fileName === 'vscode.empty.json') {
if (settings.includeVscode === false) {
// Write empty vscode.json when disabled
const vscodeOutputPath = GLib.build_filenamev([
this.themeDir,
'vscode.json',
]);
this._processTemplate(
templatePath,
vscodeOutputPath,
variables,
'vscode.empty.json',
appOverrides
);
}
return;
}

// If this is neovim.lua and a custom config is selected, write it directly
if (
fileName === 'neovim.lua' &&
Expand Down Expand Up @@ -305,7 +332,7 @@ export class ConfigWriter {
console.log(`Copied wallpaper to: ${destPath}`);
}

const variables = this._buildVariables(colorRoles);
const variables = this._buildVariables(colorRoles, lightMode);
this._processTemplatesToDirectory(
variables,
exportPath,
Expand Down Expand Up @@ -362,6 +389,25 @@ export class ConfigWriter {

const outputPath = GLib.build_filenamev([exportPath, fileName]);

// Handle vscode.empty.json - use when VSCode is disabled
if (fileName === 'vscode.empty.json') {
if (settings.includeVscode === false) {
// Write empty vscode.json when disabled
const vscodeOutputPath = GLib.build_filenamev([
exportPath,
'vscode.json',
]);
this._processTemplate(
templatePath,
vscodeOutputPath,
variables,
'vscode.empty.json',
appOverrides
);
}
return;
}

// If this is neovim.lua and a custom config is selected, write it directly
if (
fileName === 'neovim.lua' &&
Expand Down Expand Up @@ -565,6 +611,66 @@ export class ConfigWriter {
}
}

_copyVscodeTheme(variables) {
try {
const homeDir = GLib.get_home_dir();
const vscodeExtensionPath = GLib.build_filenamev([
homeDir,
'.vscode',
'extensions',
'theme-aether',
]);

// Ensure the extension directory exists
ensureDirectoryExists(vscodeExtensionPath);

// Process the entire vscode-extension folder from templates
const vscodeTemplateDir = GLib.build_filenamev([
this.templatesDir,
'vscode-extension',
]);

// Copy and process all files from vscode-extension template
this._copyVscodeExtensionDirectory(
vscodeTemplateDir,
vscodeExtensionPath,
variables
);

console.log(
`Installed VSCode extension to: ${vscodeExtensionPath}`
);
} catch (e) {
console.error('Error copying VSCode theme:', e.message);
}
}

_copyVscodeExtensionDirectory(sourceDir, destDir, variables) {
enumerateDirectory(sourceDir, (fileInfo, filePath, fileName) => {
const fileType = fileInfo.get_file_type();

if (fileType === Gio.FileType.DIRECTORY) {
// Recursively process subdirectories
const subSourceDir = GLib.build_filenamev([
sourceDir,
fileName,
]);
const subDestDir = GLib.build_filenamev([destDir, fileName]);
ensureDirectoryExists(subDestDir);
this._copyVscodeExtensionDirectory(
subSourceDir,
subDestDir,
variables
);
} else if (fileType === Gio.FileType.REGULAR) {
// Process and copy file
const destPath = GLib.build_filenamev([destDir, fileName]);
this._processTemplate(filePath, destPath, variables, fileName);
console.log(`Processed VSCode extension file: ${fileName}`);
}
});
}

_copyGtkFile(sourcePath, destPath, label) {
try {
// Remove existing file if it exists
Expand Down
19 changes: 19 additions & 0 deletions templates/vscode-extension/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{
"name": "theme-aether",
"displayName": "Aether Theme",
"description": "Aether color theme generated from wallpaper",
"version": "1.0.0",
"engines": {
"vscode": "^1.70.0"
},
"categories": ["Themes"],
"contributes": {
"themes": [
{
"label": "Aether",
"uiTheme": "vs-{theme_type}",
"path": "./themes/aether-color-theme.json"
}
]
}
}
Loading