Breathing-block status indicator (blue/green/red) #10

Merged
yuri merged 6 commits from feat/breathing-block into main 2026-10-27 22:50:24 +01:00
2 changed files with 28 additions and 6 deletions
Showing only changes of commit 71780291a3 - Show all commits
+19 -3
View File
@@ -112,6 +112,10 @@ ui_quiet_run() {
if (( nc >= 256 )); then depth=256 if (( nc >= 256 )); then depth=256
elif (( nc >= 8 )); then depth=16 elif (( nc >= 8 )); then depth=16
fi 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=() local -a bg=()
case "$depth" in case "$depth" in
@@ -119,7 +123,9 @@ ui_quiet_run() {
# shades must differ enough to survive flicker fusion — a subtle ramp # shades must differ enough to survive flicker fusion — a subtle ramp
# at 20fps reads as a solid block (VM-proven). # 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" ) ;; 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 esac
local -a ch=( "|" "/" "-" "\\" ) local -a ch=( "|" "/" "-" "\\" )
@@ -131,10 +137,20 @@ ui_quiet_run() {
| grep -E '^(Installing|Upgrading|Downgrading|Removing|Verifying|Preparing|Cleanup):' \ | grep -E '^(Installing|Upgrading|Downgrading|Removing|Verifying|Preparing|Cleanup):' \
| tail -n 1 || true) | tail -n 1 || true)
if (( depth >= 16 )); then if (( depth >= 16 )); then
local code="${bg[$(( f % ${#bg[@]} ))]}"
if [[ -n "$code" ]]; then
if [[ -n "$cur" ]]; then if [[ -n "$cur" ]]; then
printf '\r\033[%sm \033[0m %s: %s' "${bg[$(( f % ${#bg[@]} ))]}" "$msg" "$cur" >&2 printf '\r\033[%sm \033[0m %s: %s' "$code" "$msg" "$cur" >&2
else else
printf '\r\033[%sm \033[0m %s' "${bg[$(( f % ${#bg[@]} ))]}" "$msg" >&2 printf '\r\033[%sm \033[0m %s' "$code" "$msg" >&2
fi
else
# 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 fi
else else
if [[ -n "$cur" ]]; then if [[ -n "$cur" ]]; then
+8 -2
View File
@@ -31,6 +31,8 @@ _ub_depth() {
if [[ "$n" -ge 256 ]]; then echo 256 if [[ "$n" -ge 256 ]]; then echo 256
elif [[ "$n" -ge 8 ]]; then echo 16 elif [[ "$n" -ge 8 ]]; then echo 16
else echo 0; fi 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 # paint one background-coloured block (a SPACE) + message
@@ -43,7 +45,7 @@ _ub_busy_loop() {
depth=$(_ub_depth) depth=$(_ub_depth)
case "$depth" in case "$depth" in
256) pal=(17 19 21 27 33 39 45 39 33 27 21 19) ;; # deep breathe: dark navy to bright blue 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 *) pal=("|" "/" "-" "\\") ;; # last-resort spinner
esac esac
while :; do while :; do
@@ -51,7 +53,11 @@ _ub_busy_loop() {
if [[ "$depth" -eq 256 ]]; then if [[ "$depth" -eq 256 ]]; then
_ub_paint "48;5;$i" "$_UB_MSG" # 256-colour cube background _ub_paint "48;5;$i" "$_UB_MSG" # 256-colour cube background
elif [[ "$depth" -eq 16 ]]; then 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 else
printf '\r[%s] %s' "$i" "$_UB_MSG" >&"$_UB_FD" printf '\r[%s] %s' "$i" "$_UB_MSG" >&"$_UB_FD"
fi fi