diff --git a/bin/omarchy-theme-colors-from-alacritty b/bin/omarchy-theme-colors-from-alacritty index 7fc77efc..a740c0ed 100755 --- a/bin/omarchy-theme-colors-from-alacritty +++ b/bin/omarchy-theme-colors-from-alacritty @@ -182,24 +182,6 @@ selection_background=${selection_background:-$foreground} selection_foreground=${selection_foreground:-$background} accent=$color4 -# Remap ANSI slots to semantic names for the output palette -bg=$color0 -red=$color1 -green=$color2 -yellow=$color3 -blue=$color4 -purple=$color5 -cyan=$color6 -fg=$color7 -muted=$color8 -bright_red=$color9 -bright_green=$color10 -bright_yellow=$color11 -bright_blue=$color12 -bright_purple=$color13 -bright_cyan=$color14 -bright_fg=$color15 - mkdir -p "$THEME_SOURCE" cat > "$COLORS_OUTPUT" < 382 )) && THEME_COLORS[mode]="light" || THEME_COLORS[mode]="dark" + else + THEME_COLORS[mode]="dark" + fi +} + # Only generate dynamic templates for themes with a colors.toml definition if [[ -f $COLORS_FILE ]]; then sed_script=$(mktemp) @@ -308,14 +332,23 @@ if [[ -f $COLORS_FILE ]]; then # Legacy compatibility: map ANSI color0..color15 and raw bg/fg to semantic names declare -A legacy_alias=( - [bg]=background [fg]=foreground - [red]=color1 [green]=color2 [yellow]=color3 - [blue]=color4 [purple]=color5 [cyan]=color6 - [bright_red]=color9 [bright_green]=color10 [bright_yellow]=color11 - [bright_blue]=color12 [bright_purple]=color13 [bright_cyan]=color14 + [bg]=background + [fg]=foreground + [red]=color1 + [green]=color2 + [yellow]=color3 + [blue]=color4 + [purple]=color5 + [cyan]=color6 + [bright_red]=color9 + [bright_green]=color10 + [bright_yellow]=color11 + [bright_blue]=color12 + [bright_purple]=color13 + [bright_cyan]=color14 ) for key in "${!legacy_alias[@]}"; do - [[ ${THEME_COLORS[$key]} ]] || THEME_COLORS[$key]="${THEME_COLORS[${legacy_alias[$key]}]}" + alias_theme_color "$key" "${legacy_alias[$key]}" done [[ ${THEME_COLORS[light_fg]} ]] || THEME_COLORS[light_fg]="${THEME_COLORS[color7]:-${THEME_COLORS[foreground]}}" @@ -340,15 +373,25 @@ if [[ -f $COLORS_FILE ]]; then # Keep semantic themes compatible with user templates that still reference # the legacy ANSI placeholders directly. declare -A ansi_alias=( - [color0]=bg [color1]=red [color2]=green - [color3]=yellow [color4]=blue [color5]=purple - [color6]=cyan [color7]=fg [color8]=muted - [color9]=bright_red [color10]=bright_green [color11]=bright_yellow - [color12]=bright_blue [color13]=bright_purple [color14]=bright_cyan + [color0]=bg + [color1]=red + [color2]=green + [color3]=yellow + [color4]=blue + [color5]=purple + [color6]=cyan + [color7]=fg + [color8]=muted + [color9]=bright_red + [color10]=bright_green + [color11]=bright_yellow + [color12]=bright_blue + [color13]=bright_purple + [color14]=bright_cyan [color15]=bright_fg ) for key in "${!ansi_alias[@]}"; do - [[ ${THEME_COLORS[$key]} ]] || THEME_COLORS[$key]="${THEME_COLORS[${ansi_alias[$key]}]}" + alias_theme_color "$key" "${ansi_alias[$key]}" done # Resolve theme mode (dark|light) with this precedence: @@ -356,16 +399,7 @@ if [[ -f $COLORS_FILE ]]; then # 2. legacy `light.mode` file shipped beside the theme # 3. background luminance auto-detect # `theme_type` is kept as an alias so existing templates ({{ theme_type }}) keep working. - [[ ${THEME_COLORS[mode]} ]] || THEME_COLORS[mode]="${THEME_COLORS[theme_type]}" - if [[ ! ${THEME_COLORS[mode]} ]]; then - if [[ -f $NEXT_THEME_DIR/light.mode ]]; then - THEME_COLORS[mode]="light" - else - 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 -gt 382 ]] && THEME_COLORS[mode]="light" || THEME_COLORS[mode]="dark" - fi - fi + resolve_theme_mode THEME_COLORS[theme_type]="${THEME_COLORS[mode]}" for key in "${!THEME_COLORS[@]}"; do diff --git a/bin/omarchy-theme-set-vscode b/bin/omarchy-theme-set-vscode index 569a9fcb..d8ea056b 100755 --- a/bin/omarchy-theme-set-vscode +++ b/bin/omarchy-theme-set-vscode @@ -3,7 +3,7 @@ # omarchy:summary=Sync Omarchy theme to VS Code, VSCodium, and Cursor # omarchy:hidden=true -VS_CODE_THEME="$HOME/.config/omarchy/current/theme/vscode.json" +VS_CODE_THEME_DESCRIPTOR="$HOME/.config/omarchy/current/theme/vscode.json" GENERATED_THEME="$HOME/.config/omarchy/current/theme/vscode-theme.json" # Install generated theme as a local extension for a given editor @@ -50,22 +50,18 @@ set_theme() { local theme_name="" - # Always deploy the generated theme so it's available in the theme picker - if [[ -f "$GENERATED_THEME" ]]; then - install_generated_extension "$ext_base/omarchy-theme" - fi - - if [[ -f "$VS_CODE_THEME" ]]; then - # Theme specifies a preferred 3rd-party extension - theme_name=$(jq -r '.name' "$VS_CODE_THEME") + if [[ -f "$VS_CODE_THEME_DESCRIPTOR" ]]; then + # Theme specifies a preferred 3rd-party extension/theme pair. + theme_name=$(jq -r '.name' "$VS_CODE_THEME_DESCRIPTOR") local extension - extension=$(jq -r '.extension' "$VS_CODE_THEME") + extension=$(jq -r '.extension' "$VS_CODE_THEME_DESCRIPTOR") if [[ -n $extension ]] && ! "$editor_cmd" --list-extensions 2>/dev/null | grep -Fxq "$extension"; then "$editor_cmd" --install-extension "$extension" >/dev/null 2>&1 fi elif [[ -f "$GENERATED_THEME" ]]; then - # No 3rd-party preference, activate the generated theme + # VS Code only discovers local color themes through an extension package. + install_generated_extension "$ext_base/omarchy-theme" theme_name="Omarchy" fi