aether icon indicating copy to clipboard operation
aether copied to clipboard

Text selection in generated Omarchy dark themes has low legibility

Open animadito opened this issue 2 weeks ago • 0 comments

The problem

A theme generated for Omarchy in dark mode produces a text selection that is hard to read. The selection background is a shade barely lighter than the terminal background, and the selected text is drawn in the background colour.

A generated dark theme with a background of #050603 produces:

selection            = "#1e1f1c"
selection_foreground = "#050603"

The fill is the background lightened by 10 percent. The text on it is the background itself. That is a contrast ratio of about 1.2:1, so selected text has low legibility in foot, kitty, ghostty and alacritty.

Light mode is fine. There the derived fill is much darker than the background and the foreground is the light background, so the pair reads well.

Reproduction

  1. Generate a theme from a dark wallpaper:

    aether --generate <dark-wallpaper> --no-apply --output /tmp/aether-check
    

    Extract and Apply in the UI produce the same file.

  2. Read the generated colors.toml. selection is the lighter background shade and selection_foreground is the background colour.

  3. Apply the theme to Omarchy. The terminal configs Omarchy generates from colors.toml carry those two values.

Example

Selected text in foot with a generated dark theme. The fill is #1e1f1c on a #050603 background and the selected text is drawn in #050603, so the selected lines are almost unreadable.

image

Omarchy resolves the pair in /usr/share/omarchy/bin/omarchy-theme-color:

[[ ${THEME_COLORS[selection]} ]]            || THEME_COLORS[selection]="${THEME_COLORS[selection_background]:-${THEME_COLORS[color8]:-${THEME_COLORS[color0]:-${THEME_COLORS[background]}}}}"
[[ ${THEME_COLORS[selection_background]} ]] || THEME_COLORS[selection_background]="${THEME_COLORS[selection]}"
[[ ${THEME_COLORS[selection_foreground]} ]] || THEME_COLORS[selection_foreground]="${THEME_COLORS[bright_foreground]}"

selection_background is absent from the generated file, so it is filled in from selection. selection_foreground is present, so Omarchy's own fallback to bright_foreground never runs. The result is a dark fill with dark text.

Root cause

The role defaults in internal/theme/state.go are:

if v, ok := s.ExtendedColors["selection_foreground"]; ok && v != "" {
    roles.SelectionForeground = v
} else {
    roles.SelectionForeground = s.Palette[0] // background
}

if v, ok := s.ExtendedColors["selection_background"]; ok && v != "" {
    roles.SelectionBackground = v
} else {
    roles.SelectionBackground = s.Palette[7] // foreground/white
}

An untouched palette pairs the background with the foreground. The template layer in internal/template/variables.go recognises that pair and derives a surface colour for the fill:

func selectionColor(vars map[string]string, lightMode bool) string {
	// The legacy default is an inverted selection pair. Omarchy v4 only has a
	// selection background token and supplies its own foreground, so derive a
	// nearby surface color instead of exporting the normal foreground as a fill.
	if vars["selection_foreground"] == vars["background"] &&
		vars["selection_background"] == vars["foreground"] {
		if lightMode {
			return color.DarkenRGB(vars["background"], 85)
		}
		return color.LightenRGB(vars["background"], 10)
	}
	return vars["selection_background"]
}

That derived fill is fine on its own. The templates also export the selection foreground, so the derived fill ends up paired with the background colour instead of a light one:

# templates/colors.v4.toml
selection            = "{selection}"
selection_foreground = "{selection_foreground}"
# templates/colors.toml
selection_foreground = "{selection_foreground}"
selection_background = "{selection_background}"
selection            = "{selection}"

Both templates export selection_foreground explicitly, which switches off Omarchy's fallback to bright_foreground.

Every stock Omarchy theme omits the key and lets Omarchy derive it:

$ grep selection /usr/share/omarchy/themes/tokyo-night/colors.toml
selection = "#292e42"

#292e42 on #1a1b26 has the same shape as the derived #1e1f1c on #050603. The only difference is that the stock themes leave the foreground to Omarchy.

History

  • 3b10c57 (2026-08-23) fixed #120, where the selection fill was the normal foreground and Omarchy supplied a second bright foreground for the text. The fix derives a surface colour instead. Between that commit and 2026-08-30 the v4 template exported only selection, so Omarchy derived the foreground and the result was readable.
  • f7f1df9c (2026-08-30, "Make Omarchy own theme runtime") added selection_foreground = "{selection_foreground}" to templates/colors.v4.toml. That commit is what brought the low legibility to v4 themes.
  • templates/colors.toml has exported the key since acf57ddc (2026-06-03), so the standalone output path has had the same problem since 3b10c57.

Why the panel and the generated file disagree

The semantic colour panel reads selection_background. The generated file exports selection. Two keys, two values, and the panel shows the one that never reaches the disk.

Extracting a palette puts selection_background back to the foreground slot, so the condition in selectionColor holds again and the derived fill is used. Editing the swatch changes selection_background, the condition no longer holds, and the edited value reaches the file. That is why changing the colour by hand works while Extract and Apply does not.

Suggested fix

Stop exporting the selection foreground from the two colors.toml templates and let Omarchy derive it from bright_foreground, the way the stock themes do.

--- a/templates/colors.v4.toml
+++ b/templates/colors.v4.toml
@@ -3,5 +3,4 @@ mode = "{mode}"

 accent = "{accent}"
 selection = "{selection}"
-selection_foreground = "{selection_foreground}"
 muted = "{muted}"
--- a/templates/colors.toml
+++ b/templates/colors.toml
@@ -12,6 +12,4 @@ background = "{background}"

 # Selection colors
-selection_foreground = "{selection_foreground}"
-selection_background = "{selection_background}"

selection_background goes from the legacy template as well, so the file does not claim two different fill colours. Omarchy fills it in from selection.

If the panel should keep showing the colour that is exported, the computed variable can follow the derived value. This is a no-op in the custom case, where selectionColor already returns selection_background:

--- a/internal/template/variables.go
+++ b/internal/template/variables.go
@@ -150,3 +150,4 @@ func BuildVariables(
 	vars["orange"] = orange
 	vars["brown"] = color.DarkenRGB(orange, 60)
 	vars["selection"] = selectionColor(vars, lightMode)
+	vars["selection_background"] = vars["selection"]

The same line is needed in RecomputeDerived at line 187, which re-derives the pair after per app overrides.

templates/foot.ini pairs the two keys and would need to follow, since the derived fill is darker than the foreground it used to be paired with:

--- a/templates/foot.ini
+++ b/templates/foot.ini
@@ -4,2 +4,2 @@
-selection-foreground={selection_foreground.strip}
-selection-background={selection_background.strip}
+selection-foreground={bright_fg.strip}
+selection-background={selection.strip}

Test

internal/template/engine_test.go already covers the derived fill. A test for the foreground would pin the pairing:

func TestBuildVariablesDerivesOmarchySelectionForeground(t *testing.T) {
	roles := sampleRoles()
	roles.SelectionForeground = roles.Background
	roles.SelectionBackground = roles.Foreground

	dark := BuildVariables(roles, false, nil)
	if got, want := dark["selection_foreground"], dark["bright_fg"]; got != want {
		t.Errorf("selection_foreground = %q, want %q", got, want)
	}
}

Would you take a pull request for this?

Happy to open one. There are two separable changes here and I would rather send what you want than guess.

The first is the template fix: two deletions, one per colors.toml template, no code changes. It restores the behaviour the v4 path had between 2026-08-23 and 2026-08-30, and it matches what every stock Omarchy theme does.

The second is the panel fix: one line in internal/template/variables.go, the same line in RecomputeDerived, and the templates/foot.ini pair, plus a test.

Either one alone leaves something half done. The template fix on its own leaves the panel showing a colour that is not exported. The panel fix on its own leaves the selection text at low legibility, because the template still overrides the foreground.

Tell me which you would prefer, one pull request for both or two separate ones, and I will keep the commits small.

Environment

  • Aether 4.32.0
  • Omarchy 4.5.0
  • foot, kitty, ghostty and alacritty are all affected, since they read the colours Omarchy generates from colors.toml

One note on the cursor swatch

Omarchy sets cursor to bright_foreground unconditionally in omarchy-theme-color, ignoring any value a theme provides. The cursor swatch in the panel cannot be reflected in an Omarchy theme. It shows up next to the selection swatch, so it is worth knowing.

animadito avatar Nov 16 '26 19:11 animadito