Rename bg/fg palette keys to background/foreground
The canonical colors.toml keys are now background/foreground, including all permutations (dark_background, darker_background, lighter_background, dark_foreground, light_foreground, bright_foreground). The old short names are gone entirely, not kept as aliases; legacy alacritty-generated themes still resolve through the ANSI color0/color7 fallback. Theme files are also regrouped: accent/selection/muted first, then the backgrounds, then the foregrounds, then the named colors. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Fable 5
parent
72d7646c64
commit
afa2839a5a
@@ -111,7 +111,7 @@ load_colors() {
|
||||
|
||||
# Plus the core slots every theme resolves, so sparse and legacy themes
|
||||
# still render a complete preview.
|
||||
for key in mode bg fg light_fg bright_fg selection_background selection_foreground dark_bg darker_bg; do
|
||||
for key in mode background foreground light_foreground bright_foreground selection_background selection_foreground dark_background darker_background; do
|
||||
[[ -n ${resolved[$key]:-} ]] && COLORS[$key]="${resolved[$key]}"
|
||||
done
|
||||
|
||||
@@ -220,7 +220,7 @@ print_color_row() {
|
||||
paint_segment() {
|
||||
local text="$1"
|
||||
local fg="$2"
|
||||
local bg="${3:-${COLORS[bg]}}"
|
||||
local bg="${3:-${COLORS[background]}}"
|
||||
|
||||
if (( COLOR_OUTPUT )) && hex_valid "$fg" && hex_valid "$bg"; then
|
||||
ansi_bg "$bg"
|
||||
@@ -244,8 +244,8 @@ print_group() {
|
||||
}
|
||||
|
||||
print_selection_sample() {
|
||||
local bg="${COLORS[bg]}"
|
||||
local fg="${COLORS[fg]}"
|
||||
local bg="${COLORS[background]}"
|
||||
local fg="${COLORS[foreground]}"
|
||||
local selection_bg="${COLORS[selection_background]}"
|
||||
local selection_fg="${COLORS[selection_foreground]}"
|
||||
|
||||
@@ -272,7 +272,7 @@ print_selection_sample() {
|
||||
print_practical_samples() {
|
||||
printf '\nTerminal/UI samples\n'
|
||||
printf ' '
|
||||
paint_segment ' normal text ' "${COLORS[fg]}"
|
||||
paint_segment ' normal text ' "${COLORS[foreground]}"
|
||||
paint_segment ' muted/comment ' "${COLORS[muted]}"
|
||||
paint_segment ' accent/link ' "${COLORS[accent]}"
|
||||
paint_segment ' error ' "${COLORS[red]}"
|
||||
@@ -285,13 +285,13 @@ print_practical_samples() {
|
||||
paint_segment ' function() ' "${COLORS[blue]}"
|
||||
paint_segment ' --flag ' "${COLORS[magenta]}"
|
||||
printf '\n '
|
||||
paint_segment ' unselected menu row ' "${COLORS[fg]}"
|
||||
paint_segment ' unselected menu row ' "${COLORS[foreground]}"
|
||||
printf '\n '
|
||||
paint_segment ' selected menu row ' "${COLORS[selection_foreground]}" "${COLORS[selection_background]}"
|
||||
printf '\n '
|
||||
paint_segment ' status/inverse ' "${COLORS[bg]}" "${COLORS[fg]}"
|
||||
paint_segment ' inactive surface ' "${COLORS[fg]}" "${COLORS[lighter_bg]}"
|
||||
paint_segment ' urgent ' "${COLORS[bg]}" "${COLORS[red]}"
|
||||
paint_segment ' status/inverse ' "${COLORS[background]}" "${COLORS[foreground]}"
|
||||
paint_segment ' inactive surface ' "${COLORS[foreground]}" "${COLORS[lighter_background]}"
|
||||
paint_segment ' urgent ' "${COLORS[background]}" "${COLORS[red]}"
|
||||
printf '\n'
|
||||
}
|
||||
|
||||
@@ -313,8 +313,8 @@ print_palette_strip() {
|
||||
|
||||
print_ansi_palette() {
|
||||
printf '\nANSI palette strips\n'
|
||||
print_palette_strip normal bg red green yellow blue magenta cyan fg
|
||||
print_palette_strip bright muted bright_red bright_green bright_yellow bright_blue bright_magenta bright_cyan bright_fg
|
||||
print_palette_strip normal background red green yellow blue magenta cyan foreground
|
||||
print_palette_strip bright muted bright_red bright_green bright_yellow bright_blue bright_magenta bright_cyan bright_foreground
|
||||
}
|
||||
|
||||
mix_hex() {
|
||||
@@ -369,7 +369,7 @@ print_neutral_ramp() {
|
||||
local direction sort_flag key hex score entry
|
||||
local -a keys entries sorted
|
||||
|
||||
keys=(darker_bg dark_bg bg lighter_bg selection muted dark_fg fg light_fg bright_fg)
|
||||
keys=(darker_background dark_background background lighter_background selection muted dark_foreground foreground light_foreground bright_foreground)
|
||||
if [[ $mode == "light" ]]; then
|
||||
direction="lightest -> darkest"
|
||||
sort_flag="-rn"
|
||||
@@ -425,15 +425,15 @@ apply_terminal_osc
|
||||
printf 'Theme: %s\n' "$theme_label"
|
||||
printf 'File: %s\n' "$colors_file"
|
||||
printf 'Mode: %s\n' "$mode"
|
||||
if [[ ${COLORS[fg]} =~ ^#[0-9A-Fa-f]{6}$ && ${COLORS[bg]} =~ ^#[0-9A-Fa-f]{6}$ ]]; then
|
||||
printf 'fg/bg contrast: %s:1\n' "$(contrast_ratio "${COLORS[fg]}" "${COLORS[bg]}")"
|
||||
if [[ ${COLORS[foreground]} =~ ^#[0-9A-Fa-f]{6}$ && ${COLORS[background]} =~ ^#[0-9A-Fa-f]{6}$ ]]; then
|
||||
printf 'foreground/background contrast: %s:1\n' "$(contrast_ratio "${COLORS[foreground]}" "${COLORS[background]}")"
|
||||
fi
|
||||
|
||||
print_gradient bg bright_fg
|
||||
print_gradient background bright_foreground
|
||||
print_neutral_ramp "$mode"
|
||||
print_group "Foundation" bg fg accent selection
|
||||
print_group "Foundation" background foreground accent selection
|
||||
print_selection_sample
|
||||
print_practical_samples
|
||||
print_ansi_palette
|
||||
print_group "Normal colors" red yellow orange green cyan blue magenta brown
|
||||
print_group "Bright colors" bright_red bright_yellow bright_green bright_cyan bright_blue bright_magenta bright_fg
|
||||
print_group "Bright colors" bright_red bright_yellow bright_green bright_cyan bright_blue bright_magenta bright_foreground
|
||||
|
||||
@@ -51,7 +51,7 @@ theme_color() {
|
||||
' "$theme_dir/colors.toml"
|
||||
}
|
||||
|
||||
bg=$(theme_color background bg)
|
||||
text=$(theme_color foreground fg)
|
||||
bg=$(theme_color background)
|
||||
text=$(theme_color foreground)
|
||||
|
||||
exec omarchy-plymouth-set "$bg" "$text" "$theme_dir/unlock.png"
|
||||
|
||||
+21
-26
@@ -125,8 +125,8 @@ resolve_theme_mode() {
|
||||
|
||||
if [[ -f $COLORS_DIR/light.mode ]]; then
|
||||
THEME_COLORS[mode]="light"
|
||||
elif [[ ${THEME_COLORS[bg]} =~ ^#[0-9A-Fa-f]{6}$ ]]; then
|
||||
bg_hex="${THEME_COLORS[bg]#\#}"
|
||||
elif [[ ${THEME_COLORS[background]} =~ ^#[0-9A-Fa-f]{6}$ ]]; then
|
||||
bg_hex="${THEME_COLORS[background]#\#}"
|
||||
lum=$(( $(printf "%d" "0x${bg_hex:0:2}") + $(printf "%d" "0x${bg_hex:2:2}") + $(printf "%d" "0x${bg_hex:4:2}") ))
|
||||
(( lum > 382 )) && THEME_COLORS[mode]="light" || THEME_COLORS[mode]="dark"
|
||||
else
|
||||
@@ -161,17 +161,12 @@ parse_colors_file() {
|
||||
resolve_theme_colors() {
|
||||
local key
|
||||
|
||||
# Canonical palette keys are bg/fg. Preserve older themes that still define
|
||||
# background/foreground by treating those semantic values as the source of
|
||||
# truth, then expose the old names as aliases for legacy consumers.
|
||||
[[ ${THEME_COLORS[background]} ]] && THEME_COLORS[bg]="${THEME_COLORS[background]}"
|
||||
[[ ${THEME_COLORS[foreground]} ]] && THEME_COLORS[fg]="${THEME_COLORS[foreground]}"
|
||||
[[ ${THEME_COLORS[bg]} ]] || THEME_COLORS[bg]="${THEME_COLORS[color0]}"
|
||||
[[ ${THEME_COLORS[fg]} ]] || THEME_COLORS[fg]="${THEME_COLORS[color7]}"
|
||||
[[ ${THEME_COLORS[bg]} ]] && THEME_COLORS[background]="${THEME_COLORS[bg]}"
|
||||
[[ ${THEME_COLORS[fg]} ]] && THEME_COLORS[foreground]="${THEME_COLORS[fg]}"
|
||||
[[ ${THEME_COLORS[bg]} ]] && THEME_COLORS[color0]="${THEME_COLORS[bg]}"
|
||||
[[ ${THEME_COLORS[fg]} ]] && THEME_COLORS[color7]="${THEME_COLORS[fg]}"
|
||||
# Canonical palette keys are background/foreground. Themes generated before
|
||||
# the semantic palette existed may only define the ANSI names.
|
||||
[[ ${THEME_COLORS[background]} ]] || THEME_COLORS[background]="${THEME_COLORS[color0]}"
|
||||
[[ ${THEME_COLORS[foreground]} ]] || THEME_COLORS[foreground]="${THEME_COLORS[color7]}"
|
||||
[[ ${THEME_COLORS[background]} ]] && THEME_COLORS[color0]="${THEME_COLORS[background]}"
|
||||
[[ ${THEME_COLORS[foreground]} ]] && THEME_COLORS[color7]="${THEME_COLORS[foreground]}"
|
||||
|
||||
# Legacy compatibility: map ANSI color0..color15 to semantic names.
|
||||
declare -A legacy_alias=(
|
||||
@@ -194,21 +189,21 @@ resolve_theme_colors() {
|
||||
alias_theme_color magenta purple
|
||||
alias_theme_color bright_magenta bright_purple
|
||||
|
||||
[[ ${THEME_COLORS[light_fg]} ]] || THEME_COLORS[light_fg]="${THEME_COLORS[color7]:-${THEME_COLORS[fg]}}"
|
||||
[[ ${THEME_COLORS[bright_fg]} ]] || THEME_COLORS[bright_fg]="${THEME_COLORS[color15]:-${THEME_COLORS[fg]}}"
|
||||
THEME_COLORS[cursor]="${THEME_COLORS[bright_fg]}"
|
||||
[[ ${THEME_COLORS[lighter_bg]} ]] || THEME_COLORS[lighter_bg]="${THEME_COLORS[color0]:-${THEME_COLORS[bg]}}"
|
||||
[[ ${THEME_COLORS[dark_fg]} ]] || THEME_COLORS[dark_fg]="${THEME_COLORS[color8]:-${THEME_COLORS[fg]}}"
|
||||
[[ ${THEME_COLORS[muted]} ]] || THEME_COLORS[muted]="${THEME_COLORS[color8]:-${THEME_COLORS[dark_fg]}}"
|
||||
[[ ${THEME_COLORS[selection]} ]] || THEME_COLORS[selection]="${THEME_COLORS[selection_background]:-${THEME_COLORS[color8]:-${THEME_COLORS[color0]:-${THEME_COLORS[bg]}}}}"
|
||||
[[ ${THEME_COLORS[light_foreground]} ]] || THEME_COLORS[light_foreground]="${THEME_COLORS[color7]:-${THEME_COLORS[foreground]}}"
|
||||
[[ ${THEME_COLORS[bright_foreground]} ]] || THEME_COLORS[bright_foreground]="${THEME_COLORS[color15]:-${THEME_COLORS[foreground]}}"
|
||||
THEME_COLORS[cursor]="${THEME_COLORS[bright_foreground]}"
|
||||
[[ ${THEME_COLORS[lighter_background]} ]] || THEME_COLORS[lighter_background]="${THEME_COLORS[color0]:-${THEME_COLORS[background]}}"
|
||||
[[ ${THEME_COLORS[dark_foreground]} ]] || THEME_COLORS[dark_foreground]="${THEME_COLORS[color8]:-${THEME_COLORS[foreground]}}"
|
||||
[[ ${THEME_COLORS[muted]} ]] || THEME_COLORS[muted]="${THEME_COLORS[color8]:-${THEME_COLORS[dark_foreground]}}"
|
||||
[[ ${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_fg]}"
|
||||
[[ ${THEME_COLORS[selection_foreground]} ]] || THEME_COLORS[selection_foreground]="${THEME_COLORS[bright_foreground]}"
|
||||
[[ ${THEME_COLORS[orange]} ]] || THEME_COLORS[orange]="${THEME_COLORS[yellow]}"
|
||||
[[ ${THEME_COLORS[brown]} ]] || THEME_COLORS[brown]=$(mix_color "${THEME_COLORS[orange]}" "#000000" 50%)
|
||||
|
||||
# Auto-derive shades from base accents when not defined and not aliased from colorN
|
||||
[[ ${THEME_COLORS[dark_bg]} ]] || THEME_COLORS[dark_bg]=$(mix_color "${THEME_COLORS[bg]}" "#000000" 25%)
|
||||
[[ ${THEME_COLORS[darker_bg]} ]] || THEME_COLORS[darker_bg]=$(mix_color "${THEME_COLORS[bg]}" "#000000" 50%)
|
||||
[[ ${THEME_COLORS[dark_background]} ]] || THEME_COLORS[dark_background]=$(mix_color "${THEME_COLORS[background]}" "#000000" 25%)
|
||||
[[ ${THEME_COLORS[darker_background]} ]] || THEME_COLORS[darker_background]=$(mix_color "${THEME_COLORS[background]}" "#000000" 50%)
|
||||
[[ ${THEME_COLORS[bright_red]} ]] || THEME_COLORS[bright_red]=$(mix_color "${THEME_COLORS[red]}" "#ffffff" 20%)
|
||||
[[ ${THEME_COLORS[bright_yellow]} ]] || THEME_COLORS[bright_yellow]=$(mix_color "${THEME_COLORS[yellow]}" "#ffffff" 20%)
|
||||
[[ ${THEME_COLORS[bright_green]} ]] || THEME_COLORS[bright_green]=$(mix_color "${THEME_COLORS[green]}" "#ffffff" 20%)
|
||||
@@ -221,14 +216,14 @@ resolve_theme_colors() {
|
||||
# Keep semantic themes compatible with consumers that still reference the
|
||||
# legacy ANSI names directly.
|
||||
declare -A ansi_alias=(
|
||||
[color0]=bg
|
||||
[color0]=background
|
||||
[color1]=red
|
||||
[color2]=green
|
||||
[color3]=yellow
|
||||
[color4]=blue
|
||||
[color5]=magenta
|
||||
[color6]=cyan
|
||||
[color7]=fg
|
||||
[color7]=foreground
|
||||
[color8]=muted
|
||||
[color9]=bright_red
|
||||
[color10]=bright_green
|
||||
@@ -236,7 +231,7 @@ resolve_theme_colors() {
|
||||
[color12]=bright_blue
|
||||
[color13]=bright_magenta
|
||||
[color14]=bright_cyan
|
||||
[color15]=bright_fg
|
||||
[color15]=bright_foreground
|
||||
)
|
||||
for key in "${!ansi_alias[@]}"; do
|
||||
alias_theme_color "$key" "${ansi_alias[$key]}"
|
||||
|
||||
@@ -129,8 +129,8 @@ cat > "$COLORS_OUTPUT" <<EOF
|
||||
accent = "$accent"
|
||||
selection = "$selection_background"
|
||||
|
||||
bg = "$background"
|
||||
fg = "$foreground"
|
||||
background = "$background"
|
||||
foreground = "$foreground"
|
||||
|
||||
color0 = "$color0"
|
||||
color1 = "$color1"
|
||||
|
||||
Reference in New Issue
Block a user