From b7552e35e4f6a308fd79a35d89d251614cc59d60 Mon Sep 17 00:00:00 2001 From: HANCORE-linux Date: Tue, 9 Jun 2026 23:36:35 +0200 Subject: [PATCH] fix(cliamp): readable accent + correct fg/bright_fg brightness The cliamp theme-set hook mapped accent=color4 and bright_fg/fg=color15/color7 verbatim. On monochrome/matte palettes color4 is a dark, low-contrast colour, yet cliamp uses accent for the title, seek bar and the key-hint background -> those become unreadable. Some palettes also define color15 darker than color7, which inverts cliamp's normal/dim text brightness. Pick bright_fg/fg by luminance (bright_fg always the brighter), and fall back to a readable, preferably coloured accent when color4 is too close to the bg. --- theme-set.d/50-cliamp.sh | 40 +++++++++++++++++++++++++++++++++++++--- 1 file changed, 37 insertions(+), 3 deletions(-) diff --git a/theme-set.d/50-cliamp.sh b/theme-set.d/50-cliamp.sh index f5846f4..d7d2eee 100755 --- a/theme-set.d/50-cliamp.sh +++ b/theme-set.d/50-cliamp.sh @@ -8,13 +8,47 @@ fi theme_dir="$HOME/.config/cliamp/themes" mkdir -p "$theme_dir" +# Relative luminance scaled to 0-255 (integer, no external deps). +_lum() { + local r=$((16#${1:0:2})) g=$((16#${1:2:2})) b=$((16#${1:4:2})) + echo $(( (2126 * r + 7152 * g + 722 * b) / 10000 )) +} + +# cliamp maps bright_fg -> normal text, fg -> dimmed text, so bright_fg must be +# the brighter of the two. Some palettes define color15 darker than color7, which +# would invert that, so pick by luminance instead of trusting the names. +if [ "$(_lum "$bright_white")" -ge "$(_lum "$normal_white")" ]; then + fg_bright="$bright_white"; fg_dim="$normal_white" +else + fg_bright="$normal_white"; fg_dim="$bright_white" +fi + +# cliamp uses accent for the title, seek bar AND the key-hint background, so it +# must stand out from the terminal background. Prefer the theme's blue, but if it +# sits too close to the background (e.g. monochrome themes) fall back to the most +# contrasting candidate so those elements stay readable. +bg_lum="$(_lum "$primary_background")" +accent="$normal_blue" +acc_diff=$(( $(_lum "$accent") - bg_lum )); acc_diff=${acc_diff#-} +if [ "$acc_diff" -lt 80 ]; then + accent="" + # first try a readable *coloured* accent (keeps a visual accent)… + for cand in "$bright_blue" "$normal_cyan" "$normal_yellow" "$normal_green" "$normal_red"; do + [ -n "$cand" ] || continue + cand_diff=$(( $(_lum "$cand") - bg_lum )); cand_diff=${cand_diff#-} + [ "$cand_diff" -ge 80 ] && { accent="$cand"; break; } + done + # …otherwise fall back to the readable foreground colour + [ -n "$accent" ] || accent="$fg_bright" +fi + cat > "$theme_dir/omarchy.toml" << EOF # Omarchy theme for cliamp # Generated by thpm — do not edit manually. -accent = "#${normal_blue}" -bright_fg = "#${bright_white}" -fg = "#${normal_white}" +accent = "#${accent}" +bright_fg = "#${fg_bright}" +fg = "#${fg_dim}" green = "#${normal_green}" yellow = "#${normal_yellow}" red = "#${normal_red}"