Share one theme color resolver across consumers

Five scripts each hand-rolled colors.toml parsing plus their own
alias/fallback cascade, and the tables had drifted: theme-osc grew a
divergent color8/color9 chain, tmux and gnome carried private mode
detection, and the preview tool duplicated the lot. The differences
never mattered for shipped themes but were a standing bug factory for
sparse user themes.

omarchy-theme-color is now the single resolver. Its cascade is a
verbatim port of the canonical theme-set-templates logic (semantic
keys, legacy colorN aliases, derived shades, selection/cursor
derivation, mode precedence), exposed as --all, --raw, or single-key
lookup with fallback.

Generated output is byte-identical across all 21 shipped themes on
every surface: 17 template files, OSC byte stream, tmux and gsettings
command logs, and previews. Sparse legacy themes now resolve the same
palette everywhere instead of five slightly different ones.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
David Heinemeier Hansson
2026-07-03 09:06:31 -07:00
co-authored by Claude Fable 5
parent 03f7420d72
commit 3bd6e72211
6 changed files with 327 additions and 296 deletions
+3 -27
View File
@@ -13,33 +13,9 @@ fi
THEME_DIR=$HOME/.local/state/omarchy/current/theme
COLORS_FILE="$THEME_DIR/colors.toml"
# In-tree light themes now declare `mode = "light"` in colors.toml instead of
# shipping a separate light.mode marker. Keep light.mode as a user-theme fallback.
theme_mode() {
[[ -f $COLORS_FILE ]] || return
awk -F= '
{
field = $1
gsub(/^[[:space:]]+|[[:space:]]+$/, "", field)
if (field == "mode") {
value = $2
gsub(/^[[:space:]]+|[[:space:]]+$/, "", value)
if (value ~ /^"/) {
sub(/^"/, "", value)
sub(/".*$/, "", value)
}
print value
exit
}
}
' "$COLORS_FILE"
}
mode=$(theme_mode)
if [[ -z $mode && -f $THEME_DIR/light.mode ]]; then
mode="light"
fi
# omarchy-theme-color resolves mode from colors.toml (`mode = "light"`), a
# legacy light.mode marker beside it, or background luminance for user themes.
mode=$(omarchy-theme-color --file "$COLORS_FILE" mode)
if [[ $mode == "light" ]]; then
gsettings set org.gnome.desktop.interface color-scheme "prefer-light"