diff --git a/style/macarchy-bar-contrast b/style/macarchy-bar-contrast index 04e2b13..5e8f099 100755 --- a/style/macarchy-bar-contrast +++ b/style/macarchy-bar-contrast @@ -30,6 +30,9 @@ LIGHT_TEXT="#f5f5f7"; LIGHT_ACTIVE="#ff453a" DARK_TEXT="#1d1d1f"; DARK_ACTIVE="#d70015" BEGIN="# >>> macarchy-bar-contrast (managed; do not edit)" END="# <<< macarchy-bar-contrast" +# Pre-rename (omarchy-bar-contrast) block: a second [bar] table; strip it on every write. +LEGACY_BEGIN="# >>> omarchy-bar-contrast (managed; do not edit)" +LEGACY_END="# <<< omarchy-bar-contrast" CAPTURE_CMD=${OMARCHY_BAR_CONTRAST_CAPTURE:-} SETTLE_GAP=${OMARCHY_BAR_CONTRAST_SETTLE_GAP:-0.5} @@ -156,13 +159,13 @@ echo "sample=$sample verdict=$verdict text=$text" >&2 current="" [[ -f $CONF ]] && current=$(sed -n "/^$BEGIN\$/,/^$END\$/p" "$CONF") -[[ $current == "$block" ]] && exit 0 # same verdict: no write, no shell reload +[[ $current == "$block" ]] && ! grep -qxF "$LEGACY_BEGIN" "$CONF" && exit 0 # same verdict: no write, no shell reload mkdir -p "$(dirname "$CONF")" tmp=$(mktemp "$CONF.XXXXXX") trap 'rm -f "$tmp"' EXIT { - [[ -f $CONF ]] && sed "/^$BEGIN\$/,/^$END\$/d" "$CONF" | sed -e :a -e '/^\n*$/{$d;N;ba' -e '}' + [[ -f $CONF ]] && sed -e "/^$BEGIN\$/,/^$END\$/d" -e "/^$LEGACY_BEGIN\$/,/^$LEGACY_END\$/d" "$CONF" | sed -e :a -e '/^\n*$/{$d;N;ba' -e '}' [[ -f $CONF && -s $CONF ]] && echo printf '%s\n' "$block" } > "$tmp" diff --git a/tests/test_bar_contrast.sh b/tests/test_bar_contrast.sh index e8d8fb8..8eb749a 100644 --- a/tests/test_bar_contrast.sh +++ b/tests/test_bar_contrast.sh @@ -116,4 +116,15 @@ check "no capture tool is a skip, not a failure" [ "$rc" -eq 0 ] check "and it says why" grep -q 'nothing to sample' <<<"$err" check "and it leaves the config untouched" [ "$(cat "$CONF")" = "$before" ] +# --- the pre-rename block is stripped ----------------------------------------- +# The rename to macarchy-core changed the markers; the old omarchy-bar-contrast +# block was left behind as a second [bar] table (invalid TOML), and the no-op +# exit meant an unchanged verdict never cleaned it up. +printf '[font]\nbase-size = 14\n' > "$CONF" +"$SCRIPT" --sample '#040407' >/dev/null 2>&1 +printf '\n# >>> omarchy-bar-contrast (managed; do not edit)\n[bar]\ntext = "#f5f5f7"\nactive = "#ff453a"\n# <<< omarchy-bar-contrast\n' >> "$CONF" +"$SCRIPT" --sample '#040407' >/dev/null 2>&1 +check "legacy block stripped on an unchanged verdict" \ + [ "$(grep -c '^\[bar\]$' "$CONF")" -eq 1 ] + echo; [[ $fails -eq 0 ]] && echo "all passed" || { echo "$fails failed"; exit 1; }