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
24 changes: 24 additions & 0 deletions src/components/SettingsSidebar.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ export const SettingsSidebar = GObject.registerClass(
// Default values
this._includeNeovim = true;
this._includeVencord = false;
this._includeZed = false;
this._includeGtk = false;
this._lightMode = false;
this._selectedNeovimConfig = null;
Expand Down Expand Up @@ -617,6 +618,26 @@ export const SettingsSidebar = GObject.registerClass(

expanderRow.add_row(vencordRow);

const zedRow = new Adw.ActionRow({
title: 'Include Zed Theme',
subtitle: 'Copy aether.zed.json to ~/.config/zed/themes/',
});

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

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

zedRow.add_suffix(this._zedSwitch);
zedRow.set_activatable_widget(this._zedSwitch);

expanderRow.add_row(zedRow);

return expanderRow;
}

Expand Down Expand Up @@ -768,6 +789,7 @@ export const SettingsSidebar = GObject.registerClass(
return {
includeNeovim: this._includeNeovim,
includeVencord: this._includeVencord,
includeZed: this._includeZed,
includeGtk: this._includeGtk,
lightMode: this._lightMode,
selectedNeovimConfig: this._selectedNeovimConfig,
Expand All @@ -786,6 +808,7 @@ export const SettingsSidebar = GObject.registerClass(
if (settings) {
this._includeNeovim = settings.includeNeovim ?? true;
this._includeVencord = settings.includeVencord ?? false;
this._includeZed = settings.includeZed ?? false;
this._includeGtk = settings.includeGtk ?? false;
this._enableAppOverrides = settings.enableAppOverrides ?? false;
console.log('Loaded settings from', this._settingsPath);
Expand All @@ -802,6 +825,7 @@ export const SettingsSidebar = GObject.registerClass(
const settings = {
includeNeovim: this._includeNeovim,
includeVencord: this._includeVencord,
includeZed: this._includeZed,
includeGtk: this._includeGtk,
enableAppOverrides: this._enableAppOverrides,
};
Expand Down
50 changes: 49 additions & 1 deletion src/utils/ConfigWriter.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,11 @@ import {
createSymlink,
} from './file-utils.js';
import {hexToRgbString, hexToRgba, hexToYaruTheme} from './color-utils.js';
import {restartSwaybg, copyVencordTheme} from './service-manager.js';
import {
restartSwaybg,
copyVencordTheme,
copyZedTheme,
} from './service-manager.js';
import {DEFAULT_COLORS} from '../constants/colors.js';
import {getAppNameFromFileName} from '../constants/templates.js';

Expand Down Expand Up @@ -68,6 +72,11 @@ export class ConfigWriter {
this._copyVencordTheme();
}

// Copy Zed theme if enabled
if (settings.includeZed === true) {
this._copyZedTheme();
}

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

Expand Down Expand Up @@ -129,6 +138,14 @@ export class ConfigWriter {
return;
}

// Skip aether.zed.json if includeZed is false
if (
fileName === 'aether.zed.json' &&
settings.includeZed === false
) {
return;
}

// Skip gtk.css if includeGtk is false
if (fileName === 'gtk.css' && settings.includeGtk === false) {
return;
Expand Down Expand Up @@ -330,6 +347,14 @@ export class ConfigWriter {
return;
}

// Skip aether.zed.json if includeZed is false
if (
fileName === 'aether.zed.json' &&
settings.includeZed === false
) {
return;
}

// Skip gtk.css if includeGtk is false
if (fileName === 'gtk.css' && settings.includeGtk === false) {
return;
Expand Down Expand Up @@ -517,6 +542,29 @@ export class ConfigWriter {
}
}

_copyZedTheme() {
try {
const zedSourcePath = GLib.build_filenamev([
this.themeDir,
'aether.zed.json',
]);

// Check if source file exists
const sourceFile = Gio.File.new_for_path(zedSourcePath);
if (!sourceFile.query_exists(null)) {
console.log(
'aether.zed.json not found in theme directory, skipping Zed copy'
);
return;
}

// Copy to ~/.config/zed/themes/
copyZedTheme(zedSourcePath);
} catch (e) {
console.error('Error copying Zed theme:', e.message);
}
}

_copyGtkFile(sourcePath, destPath, label) {
try {
// Remove existing file if it exists
Expand Down
48 changes: 48 additions & 0 deletions src/utils/service-manager.js
Original file line number Diff line number Diff line change
Expand Up @@ -119,3 +119,51 @@ export function copyVencordTheme(sourcePath) {

return successCount;
}

/**
* Copies Zed theme to ~/.config/zed/themes/
* @param {string} sourcePath - Path to the aether.zed.json file
* @returns {boolean} Success status
*/
export function copyZedTheme(sourcePath) {
// Validate source path
if (!sourcePath) {
console.error('copyZedTheme: sourcePath is required');
return false;
}

const sourceFile = Gio.File.new_for_path(sourcePath);
if (!sourceFile.query_exists(null)) {
console.error(`copyZedTheme: Source file not found: ${sourcePath}`);
return false;
}

const configDir = GLib.get_user_config_dir();
const OUTPUT_FILENAME = 'aether.json';

try {
const zedThemesPath = GLib.build_filenamev([
configDir,
'zed',
'themes',
]);

// Ensure the themes directory exists
ensureDirectoryExists(zedThemesPath);

// Copy the theme file
const destPath = GLib.build_filenamev([zedThemesPath, OUTPUT_FILENAME]);
const success = copyFile(sourcePath, destPath);

if (success) {
console.log(`Copied Zed theme to: ${destPath}`);
return true;
} else {
console.error(`Failed to copy Zed theme to: ${destPath}`);
return false;
}
} catch (e) {
console.error(`Error copying Zed theme:`, e.message);
return false;
}
}
Loading