TTY: on/off block pulse on the Linux console (shade fusion defeated)

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.
This commit is contained in:
Pathfinder
2026-10-27 22:41:48 +01:00
parent 3d21a1c427
commit 71780291a3
2 changed files with 28 additions and 6 deletions
+20 -4
View File
@@ -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
+8 -2
View File
@@ -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