Files
omarchycn/bin/omarchy-theme-osc
T
David Heinemeier HanssonandClaude Fable 5 3bd6e72211 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>
2026-07-03 09:06:31 -07:00

34 lines
731 B
Bash
Executable File

#!/bin/bash
# omarchy:summary=Print OSC sequences for an Omarchy color theme
# omarchy:hidden=true
theme="${1:-$HOME/.local/state/omarchy/current/theme/colors.toml}"
[[ -f $theme ]] || exit 0
declare -A COLORS
while IFS=$'\t' read -r key value; do
COLORS[$key]="$value"
done < <(omarchy-theme-color --file "$theme" --all)
emit_osc() {
local code="$1"
local key="$2"
[[ -n ${COLORS[$key]:-} ]] || return 0
printf '\033]%s;%s\007' "$code" "${COLORS[$key]}"
}
emit_osc 10 foreground
emit_osc 11 background
emit_osc 12 cursor
emit_osc 17 selection_background
emit_osc 19 selection_foreground
for i in {0..15}; do
[[ -n ${COLORS[color$i]:-} ]] || continue
printf '\033]4;%d;%s\007' "$i" "${COLORS[color$i]}"
done