From 71780291a3c4c5f709bbb587172ceba93a4191ff Mon Sep 17 00:00:00 2001 From: Pathfinder Date: Tue, 27 Oct 2026 22:41:48 +0100 Subject: [PATCH] TTY: on/off block pulse on the Linux console (shade fusion defeated) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit YuKu tests on the bare Linux VT (not a terminal emulator): my 16-colour fallback alternated blue (44) / bright blue (104), which render nearly identically on VGA consoles -> fused into 'solid blue'. If TERM misreports 256, 48;5;N codes are ignored outright. Fixes: - TERM linux*/console* forces the 16-colour path regardless of tput. - 16-colour mode now PULSES THE BLOCK ON/OFF (2 frames blue block, 2 frames no block, ~2.5Hz) instead of shade alternation — visible on any console hardware, no colour fidelity required. - 256-colour terminals keep the deep 17->45 breathe ramp. Verified: TERM=linux pty shows block/no-block alternation with zero 48;5 codes; TERM=xterm-256color keeps the 8-shade ramp; unattended + piped regressions green. --- lib/common.sh | 24 ++++++++++++++++++++---- lib/ui-block.sh | 10 ++++++++-- 2 files changed, 28 insertions(+), 6 deletions(-) diff --git a/lib/common.sh b/lib/common.sh index e5568a2..9426176 100644 --- a/lib/common.sh +++ b/lib/common.sh @@ -112,6 +112,10 @@ ui_quiet_run() { if (( nc >= 256 )); then depth=256 elif (( nc >= 8 )); then depth=16 fi + # The bare Linux VT is 16-color VGA: 48;5;N codes are ignored there, and + # its blue/bright-blue backgrounds render nearly identically (VM-proven: + # "solid blue, no breathing" on the console). Cap to the 16-color path. + case "${TERM:-}" in linux*|console*) depth=16 ;; esac local -a bg=() case "$depth" in @@ -119,7 +123,9 @@ ui_quiet_run() { # shades must differ enough to survive flicker fusion — a subtle ramp # at 20fps reads as a solid block (VM-proven). 256) bg=( "48;5;17" "48;5;19" "48;5;21" "48;5;27" "48;5;33" "48;5;39" "48;5;45" "48;5;39" "48;5;33" "48;5;27" "48;5;21" "48;5;19" ) ;; - 16) bg=( "44" "104" "44" "104" ) ;; + # On/off pulse, NOT shade alternation: console blues fuse to solid. + # Empty element = frame without the block (block breathes in/out). + 16) bg=( "44" "44" "" "" ) ;; esac local -a ch=( "|" "/" "-" "\\" ) @@ -131,10 +137,20 @@ ui_quiet_run() { | grep -E '^(Installing|Upgrading|Downgrading|Removing|Verifying|Preparing|Cleanup):' \ | tail -n 1 || true) if (( depth >= 16 )); then - if [[ -n "$cur" ]]; then - printf '\r\033[%sm \033[0m %s: %s' "${bg[$(( f % ${#bg[@]} ))]}" "$msg" "$cur" >&2 + local code="${bg[$(( f % ${#bg[@]} ))]}" + if [[ -n "$code" ]]; then + if [[ -n "$cur" ]]; then + printf '\r\033[%sm \033[0m %s: %s' "$code" "$msg" "$cur" >&2 + else + printf '\r\033[%sm \033[0m %s' "$code" "$msg" >&2 + fi else - printf '\r\033[%sm \033[0m %s' "${bg[$(( f % ${#bg[@]} ))]}" "$msg" >&2 + # block "breathes out": just the text that frame + if [[ -n "$cur" ]]; then + printf '\r %s: %s' "$msg" "$cur" >&2 + else + printf '\r %s' "$msg" >&2 + fi fi else if [[ -n "$cur" ]]; then diff --git a/lib/ui-block.sh b/lib/ui-block.sh index bc08152..f5d36a6 100644 --- a/lib/ui-block.sh +++ b/lib/ui-block.sh @@ -31,6 +31,8 @@ _ub_depth() { if [[ "$n" -ge 256 ]]; then echo 256 elif [[ "$n" -ge 8 ]]; then echo 16 else echo 0; fi + # bare Linux VT: cap regardless of what tput reports + case "${TERM:-}" in linux*|console*) echo 16 ;; esac } # paint one background-coloured block (a SPACE) + message @@ -43,7 +45,7 @@ _ub_busy_loop() { depth=$(_ub_depth) case "$depth" in 256) pal=(17 19 21 27 33 39 45 39 33 27 21 19) ;; # deep breathe: dark navy to bright blue - 16) pal=(44 104 44 104) ;; # blue / bright blue + 16) pal=(44 44 "" "") ;; # on/off pulse: console blues fuse *) pal=("|" "/" "-" "\\") ;; # last-resort spinner esac while :; do @@ -51,7 +53,11 @@ _ub_busy_loop() { if [[ "$depth" -eq 256 ]]; then _ub_paint "48;5;$i" "$_UB_MSG" # 256-colour cube background elif [[ "$depth" -eq 16 ]]; then - _ub_paint "$i" "$_UB_MSG" # plain ANSI background (44/104) + if [[ -n "$i" ]]; then + _ub_paint "$i" "$_UB_MSG" # plain ANSI background (blue) + else + printf '\r %s' "$_UB_MSG" >&"$_UB_FD" # block breathes out + fi else printf '\r[%s] %s' "$i" "$_UB_MSG" >&"$_UB_FD" fi