Skip to content

Commit 34b430b

Browse files
committed
theme switching
1 parent 19053cc commit 34b430b

File tree

1 file changed

+89
-63
lines changed

1 file changed

+89
-63
lines changed

README.md

Lines changed: 89 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,9 @@ A tiny, no-nonsense app launcher. Press `⌘ Space`, type a few letters, hit `En
1212

1313
- **Global hotkey**: toggles with `⌘ Space` (configurable in code).
1414
- **Fuzzy search**: type fragments like `gc` → finds “Google Chrome”.
15-
- **Multi-monitor aware**: opens on the active display; plays nicely with separate Spaces.
16-
- **Hot-reload config**: edit `config.toml` and it live-applies (colors, fonts, size).
15+
- **Multi‑monitor aware**: opens on the active display; plays nicely with separate Spaces.
16+
- **Hot‑reload config**: edit `config.toml` and it live‑applies (colors, fonts, size).
17+
- **Theme filtering & switching**: press `Ctrl‑T` to filter themes by name and apply instantly.
1718
- **Lightweight**: ~20 MB RAM, instant launch.
1819
- **Window switching**: list running app windows and jump to them (across Spaces).
1920

@@ -28,7 +29,7 @@ A tiny, no-nonsense app launcher. Press `⌘ Space`, type a few letters, hit `En
2829
- `/System/Applications`
2930
- `~/Applications`
3031
- **Launching**: opens the selected `.app` bundle.
31-
- **Switching**: focuses an existing app/window using Accessibility APIs plus a small amount of Mission Control key-emulation (see below).
32+
- **Switching**: focuses an existing app/window using Accessibility APIs plus a small amount of Mission Control keyemulation (see below).
3233

3334
---
3435

@@ -41,14 +42,14 @@ YAL gathers a snapshot of displays → spaces → windows, then focuses the one
4142
- list managed displays and their Spaces (`CGSCopyManagedDisplaySpaces`),
4243
- enumerate windows per Space (`SLSCopyWindowsWithOptionsAndTags` + iterators),
4344
- infer window type (normal/utility/fullscreen/minimized) from **level** and **tag** bits.
44-
(Heuristics include flags like `TAG_HAS_TITLEBAR_LIKE`, and “minimized-ish” masks observed on recent macOS builds.)
45+
(Heuristics include flags like `TAG_HAS_TITLEBAR_LIKE`, and “minimizedish” masks observed on recent macOS builds.)
4546

4647
- **Metadata enrichment (CoreGraphics)**
4748
Separately reads the public `CGWindowListCopyWindowInfo` snapshot to attach **PID**, **owner name**, and **title** to each window ID. This is also why YAL needs **Screen Recording** permission (macOS requires it to access full window metadata).
4849

4950
- **Space targeting**
5051
To jump across Spaces, YAL identifies the **display** that contains the target Space, warps the cursor to that display’s center (so Mission Control shortcuts address the right display), then:
51-
- uses `Control + <digit>` for Spaces 1–10 when available, or
52+
- uses `Control + <digit>` for Desktops 1–10 when available, or
5253
- `Control + Left/Right` to walk to the desired index.
5354

5455
- **Focusing the exact window (AX)**
@@ -105,7 +106,7 @@ Tested on Apple Silicon with **macOS 15+**.
105106

106107
YAL needs both:
107108

108-
- **Accessibility** (to focus/raise windows)
109+
- **Accessibility** (to focus/raise windows and post Mission Control keys)
109110
- **Screen Recording** (to read window metadata via CGWindow)
110111

111112
System Settings → **Privacy & Security****Accessibility** and **Screen Recording**.
@@ -116,13 +117,13 @@ For switching to work effectively, make sure Mission Control shortcuts are turne
116117
**System Settings****Keyboard****Keyboard Shortcuts…****Mission Control** → enable:
117118
- **Move left a space**`Control + Left Arrow`
118119
- **Move right a space**`Control + Right Arrow`
119-
- **Move to space 1…10**`Control + 1…0`
120+
- **Switch to Desktop 1…10**`Control + 1…0`
120121

121122
If you use multiple monitors, “Displays have separate Spaces” is recommended.
122123

123124
### Autostart
124125

125-
Since YAL is long-running, consider adding it to **Login Items**.
126+
Since YAL is longrunning, consider adding it to **Login Items**.
126127

127128
### Disable Spotlight’s shortcut
128129

@@ -137,72 +138,100 @@ Spotlight also binds `⌘ Space`. Pick one:
137138

138139
- `⌘ Space` — toggle YAL
139140
- Type to search (fuzzy match)
140-
- `Up/Down` or `Ctrl-p` / `Ctrl-n` — navigate
141+
- `Up/Down` or `Ctrlp` / `Ctrln` — navigate
141142
- `Enter` — launch selected app **or** switch to its window (if in switch mode)
142143
- `Esc` — close YAL
143-
- `Ctrl-o` / `Ctrl-f` — toggle between **app** and **switch** mode
144-
_(YAL remembers the last mode you used.)_
144+
- `Ctrl‑o` — toggle **App** mode
145+
- `Ctrl‑f` — toggle **Switch** (windows) mode
146+
- `Ctrl‑t` — toggle **Themes** mode (filter themes; `Enter` applies the highlighted theme)
147+
148+
> Theme switching is instant. Applied themes persist by writing the `theme` key in your `config.toml` (see below).
145149
146150
---
147151

148152
## Configuration
149153

150-
YAL reads a TOML file and hot-reloads it on change.
154+
YAL reads TOML files from your XDG config directory and hot‑reloads on change.
155+
156+
**Locations**
151157

152-
**Location**
158+
- `~/.config/yal/config.toml` (main app config)
159+
- `~/.config/yal/themes.toml` (named theme definitions)
153160

154-
- `~/.config/yal/config.toml`
161+
### Quick start: example files
155162

156-
**Example**
163+
**`~/.config/yal/themes.toml`**
164+
```toml
165+
# Define one or more named themes. Keys are color hex strings.
166+
# You can reference any section name here from `config.toml`'s `theme` key.
167+
168+
[catppuccin-mocha]
169+
bg_color = "#1e1e2e"
170+
fg_color = "#45475a"
171+
bg_font_color = "#cdd6f4"
172+
fg_font_color = "#cdd6f4"
173+
174+
[custom]
175+
bg_color = "#0f0f14"
176+
fg_color = "#2f81f7"
177+
bg_font_color = "#e6e6e6"
178+
fg_font_color = "#ffffff"
179+
```
157180

181+
**`~/.config/yal/config.toml`**
158182
```toml
159-
# ~/.config/yal/config.toml
160-
161-
# UI
162-
font = "ui-monospace, SFMono-Regular, Menlo, monospace"
163-
font_size = 14.0
164-
165-
# Colors (CSS)
166-
bg_color = "#111111" # app background
167-
fg_color = "#2a6ff0" # highlight background for the selected row
168-
bg_font_color = "#e6e6e6" # normal text color (on bg_color)
169-
fg_font_color = "#ffffff" # text color on the highlighted row
170-
171-
# Window (logical points)
172-
w_width = 720.0
173-
w_height = 380.0
174-
175-
# Layout
176-
align_h = "center" # left | center | right
177-
align_v = "top" # top | center | bottom
178-
margin_x = 12.0 # px inset for left/right align
179-
margin_y = 12.0 # px inset for top/bottom align
180-
padding = 6.0 # inner padding
181-
line_height = 1.2 # line height multiplier
182-
w_radius = 10.0 # corner radius in px
183+
# Pick a theme by name (must exist in themes.toml).
184+
theme = "catppuccin-mocha"
185+
186+
[font]
187+
font = "Fira Code" # CSS font stack allowed
188+
font_size = 12.0 # px
189+
190+
[window]
191+
w_width = 400.0 # logical points
192+
w_height = 250.0
193+
align_h = "center" # left | center | right
194+
align_v = "center" # top | center | bottom
195+
line_height = 0.8
196+
padding = 8
197+
w_radius = 0
183198
```
184199

200+
> Any change you save will be applied live. If you change `theme = ...`, the UI updates immediately. `Ctrl‑T` in YAL lets you preview and apply a theme without editing files; it writes back the selected theme name to `config.toml` for persistence.
201+
185202
### Config reference
186203

187-
| Key | Type | Description |
188-
|-----------------|--------|-------------------------------------------------------------------------------------------------------|
189-
| `font` | string | CSS `font-family` stack applied to the UI. |
190-
| `font_size` | float | Base font size in **px** (e.g., `14.0`). |
191-
| `bg_color` | string | App background color (CSS color). |
192-
| `fg_color` | string | **Row highlight background** for the selected item. |
193-
| `bg_font_color` | string | Text color for normal rows (text on `bg_color`). |
194-
| `fg_font_color` | string | Text color for the selected row (text on `fg_color`). |
195-
| `w_width` | float | Window width in logical points. |
196-
| `w_height` | float | Window height in logical points. |
197-
| `align_h` | enum | Horizontal alignment on the active display: `"left"` \| `"center"` \| `"right"`. |
198-
| `align_v` | enum | Vertical alignment on the active display: `"top"` \| `"center"` \| `"bottom"`. |
199-
| `margin_x` | float | Horizontal inset (in px) used when `align_h` is `"left"` or `"right"`. |
200-
| `margin_y` | float | Vertical inset (in px) used when `align_v` is `"top"` or `"bottom"`. |
201-
| `padding` | float | Inner padding of the window (in px). |
202-
| `line_height` | float | Line height multiplier for rows (e.g., `1.2`). |
203-
| `w_radius` | float | Window corner radius (in px). |
204-
205-
> Any value you omit falls back to the built-in defaults. Save the file while YAL is open to see live updates.
204+
#### Theme (from `themes.toml`)
205+
206+
Each **theme** is a `[name]` table with these keys:
207+
208+
| Key | Type | Description |
209+
|------------------|--------|---------------------------------------------------------|
210+
| `bg_color` | string | App background color (CSS hex or named color). |
211+
| `fg_color` | string | Row highlight background for the selected item. |
212+
| `bg_font_color` | string | Text color for normal rows (on `bg_color`). |
213+
| `fg_font_color` | string | Text color on the highlighted row (on `fg_color`). |
214+
215+
> Reference a theme in `config.toml` via `theme = "<name>"`.
216+
217+
#### Font (`[font]` in `config.toml`)
218+
219+
| Key | Type | Description |
220+
|--------------|--------|-----------------------------------------------------------------|
221+
| `font` | string | CSS `font-family` stack applied to the UI. |
222+
| `font_size` | float | Base font size in **px** (e.g., `14.0`). |
223+
224+
#### Window (`[window]` in `config.toml`)
225+
226+
| Key | Type | Description |
227+
|---------------|--------|-----------------------------------------------------------------------------|
228+
| `w_width` | float | Window width in logical points. |
229+
| `w_height` | float | Window height in logical points. |
230+
| `align_h` | enum | Horizontal alignment: `"left"` \| `"center"` \| `"right"`. |
231+
| `align_v` | enum | Vertical alignment: `"top"` \| `"center"` \| `"bottom"`. |
232+
| `padding` | float | Inner padding (px). |
233+
| `line_height` | float | Line height multiplier for rows (e.g., `1.2`). |
234+
| `w_radius` | float | Corner radius (px). |
206235

207236
---
208237

@@ -215,16 +244,13 @@ w_radius = 10.0 # corner radius in px
215244
That’s intentional; it hides on blur. Press `⌘ Space` again.
216245

217246
- **Colors/fonts don’t change**
218-
Confirm you’re editing `~/.config/yal/config.toml` (or `$XDG_CONFIG_HOME/yal/config.toml`). Save and give it a second—YAL hot-reloads.
219-
220-
- **App doesn’t appear**
221-
Make sure it’s an `.app` bundle in `/Applications`, `/System/Applications`, or `~/Applications`.
247+
Confirm you’re editing files in `~/.config/yal/`. Save and give it a second—YAL hot‑reloads.
222248

223249
- **Window switching doesn’t work**
224250
- Grant **Accessibility** and **Screen Recording** permissions.
225251
- Ensure Mission Control shortcuts are enabled (see above).
226252
- Quit and relaunch YAL after granting permissions.
227-
- Some apps (or non-standard windows) may not expose the right metadata.
253+
- Some apps (or nonstandard windows) may not expose the right metadata.
228254

229255
---
230256

0 commit comments

Comments
 (0)