Skip to content

Commit f87b00e

Browse files
committed
Read theme colors from colors.toml instead of aether.override.css
Prefer the active omarchy theme's colors.toml so Aether's UI reflects the live system theme, falling back to Aether's own generated output. Adds GetThemeColors() so the frontend can pull on mount and avoid a race with the watcher's startup emit.
1 parent 9ce8e5d commit f87b00e

9 files changed

Lines changed: 192 additions & 338 deletions

File tree

app.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,12 @@ func (a *App) IsMacOS() bool { return runtime.GOOS == "darwin" }
6262
// GetFocusTab returns the tab to focus on startup (empty = default editor).
6363
func (a *App) GetFocusTab() string { return a.focusTab }
6464

65+
// GetThemeColors returns the current parsed colors.toml map. Frontend
66+
// pulls this on mount; the event-emit race means push alone isn't safe.
67+
func (a *App) GetThemeColors() map[string]string {
68+
return a.themeWatcher.CurrentColors()
69+
}
70+
6571
// NewApp creates a new App instance.
6672
func NewApp() *App {
6773
return &App{

docs/filesystem.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,7 @@ User settings and persistent data.
1818
│ └── *.conf # Processed config files
1919
├── favorites.json # Favorited wallpapers list
2020
├── settings.json # App preferences
21-
├── wallhaven.json # Wallhaven API key and settings
22-
└── theme.override.css # Symlink to theme/aether.override.css
21+
└── wallhaven.json # Wallhaven API key and settings
2322
```
2423

2524
### Key Files

docs/standalone.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ When you click "Apply Theme", Aether generates all theme files to:
2222
├── kitty.conf # Kitty terminal theme
2323
├── waybar.css # Waybar stylesheet
2424
├── gtk.css # GTK theme (if enabled)
25-
├── aether.override.css # Aether app theme
25+
├── colors.toml # Palette source (read by Aether's own UI)
2626
├── neovim.lua # Neovim colorscheme (if enabled)
2727
├── vscode.json # VSCode color theme (if enabled)
2828
├── aether.zed.json # Zed editor theme (if enabled)

frontend/src/App.svelte

Lines changed: 65 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -195,69 +195,72 @@
195195
'../wailsjs/runtime/runtime'
196196
);
197197
198-
// Apply theme colors from aether.override.css as CSS custom properties
199-
EventsOn(
200-
'theme-colors-changed',
201-
(colors: Record<string, string>) => {
202-
const root = document.documentElement;
203-
for (const [name, value] of Object.entries(colors)) {
204-
root.style.setProperty(`--aether-${name}`, value);
205-
}
206-
// Map key GTK colors to our Tailwind theme tokens
207-
if (colors.background) {
208-
root.style.setProperty(
209-
'--color-bg-primary',
210-
colors.background
211-
);
212-
root.style.setProperty(
213-
'--color-bg-secondary',
214-
colors.background
215-
);
216-
document.body.style.background = colors.background;
217-
// Update native window/titlebar color to match theme
218-
const rgb = hexToRgb(colors.background);
219-
WindowSetBackgroundColour(rgb.r, rgb.g, rgb.b, 255);
220-
}
221-
if (colors.foreground) {
222-
root.style.setProperty(
223-
'--color-fg-primary',
224-
colors.foreground
225-
);
226-
document.body.style.color = colors.foreground;
227-
}
228-
if (colors.blue) {
229-
root.style.setProperty(
230-
'--color-accent',
231-
colors.blue
232-
);
233-
}
234-
if (colors.red) {
235-
root.style.setProperty(
236-
'--color-destructive',
237-
colors.red
238-
);
239-
}
240-
if (colors.green) {
241-
root.style.setProperty(
242-
'--color-success',
243-
colors.green
244-
);
245-
}
246-
if (colors.yellow) {
247-
root.style.setProperty(
248-
'--color-warning',
249-
colors.yellow
250-
);
251-
}
252-
// Cache for instant restore on next launch
253-
try {
254-
localStorage.setItem(
255-
'aether-theme-colors',
256-
JSON.stringify(colors)
257-
);
258-
} catch {}
198+
const applyThemeColors = (colors: Record<string, string>) => {
199+
const root = document.documentElement;
200+
for (const [name, value] of Object.entries(colors)) {
201+
root.style.setProperty(`--aether-${name}`, value);
259202
}
260-
);
203+
if (colors.background) {
204+
root.style.setProperty(
205+
'--color-bg-primary',
206+
colors.background
207+
);
208+
root.style.setProperty(
209+
'--color-bg-secondary',
210+
colors.background
211+
);
212+
document.body.style.background = colors.background;
213+
const rgb = hexToRgb(colors.background);
214+
WindowSetBackgroundColour(rgb.r, rgb.g, rgb.b, 255);
215+
}
216+
if (colors.foreground) {
217+
root.style.setProperty(
218+
'--color-fg-primary',
219+
colors.foreground
220+
);
221+
document.body.style.color = colors.foreground;
222+
}
223+
if (colors.blue) {
224+
root.style.setProperty('--color-accent', colors.blue);
225+
}
226+
if (colors.red) {
227+
root.style.setProperty(
228+
'--color-destructive',
229+
colors.red
230+
);
231+
}
232+
if (colors.green) {
233+
root.style.setProperty('--color-success', colors.green);
234+
}
235+
if (colors.yellow) {
236+
root.style.setProperty(
237+
'--color-warning',
238+
colors.yellow
239+
);
240+
}
241+
// Read synchronously by index.html at first paint to
242+
// avoid a flash before the Wails bridge is ready.
243+
try {
244+
localStorage.setItem(
245+
'aether-theme-colors',
246+
JSON.stringify(colors)
247+
);
248+
} catch {}
249+
};
250+
251+
EventsOn('theme-colors-changed', applyThemeColors);
252+
253+
// Pull before subscribing-is-too-late: EventsOn attaches
254+
// after the watcher's startup emit has already fired.
255+
try {
256+
const {GetThemeColors} = await import(
257+
'../wailsjs/go/main/App'
258+
);
259+
const colors = await GetThemeColors();
260+
if (colors && Object.keys(colors).length > 0) {
261+
applyThemeColors(colors);
262+
}
263+
} catch {}
261264
262265
// Listen for IPC remote control state changes
263266
EventsOn(

frontend/wailsjs/go/main/App.d.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,8 @@ export function GetSettings(): Promise<Record<string, any>>;
7272

7373
export function GetTemplateColors(): Promise<Record<string, Array<string>>>;
7474

75+
export function GetThemeColors(): Promise<Record<string, string>>;
76+
7577
export function GetThumbnail(arg1: string): Promise<string>;
7678

7779
export function GetWallhavenConfig(): Promise<Record<string, any>>;

frontend/wailsjs/go/main/App.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,10 @@ export function GetTemplateColors() {
9898
return window['go']['main']['App']['GetTemplateColors']();
9999
}
100100

101+
export function GetThemeColors() {
102+
return window['go']['main']['App']['GetThemeColors']();
103+
}
104+
101105
export function GetThumbnail(arg1) {
102106
return window['go']['main']['App']['GetThumbnail'](arg1);
103107
}

0 commit comments

Comments
 (0)