# ── animations.zsh : splash functions + TTY-guarded startup ────────────────── assert_ok "planet.zsh parses" zsh -n "$DOTFILES/scripts/planet.zsh" assert_ok "planet defined" zsh -ic 'source $DOTFILES/config/animations.zsh; typeset -f planet >/dev/null' assert_ok "silk defined" zsh -ic 'source $DOTFILES/config/animations.zsh; typeset -f silk >/dev/null' assert_ok "silk compiles" python3 -m py_compile "$HOME/.local/bin/silk" assert_ok "silk knows bloom" sh -c '"$HOME/.local/bin/silk" --help | grep -q "^ bloom "' assert_ok "silk knows cross" sh -c '"$HOME/.local/bin/silk" --help | grep -q "^ cross "' assert_ok "bloom is login default" zsh -ic 'source $DOTFILES/config/animations.zsh; [[ $SILK_MODE == bloom ]]' # a non-tty run must be a silent no-op (never block a script) assert_ok "silk no-op off tty" sh -c 'SILK_MODE=bloom SILK_TIMEOUT=0.2 "$HOME/.local/bin/silk" /dev/null' assert_ok "cross defined" zsh -ic 'source $DOTFILES/config/animations.zsh; typeset -f cross >/dev/null' assert_ok "crossmode defined" zsh -ic 'source $DOTFILES/config/animations.zsh; typeset -f crossmode >/dev/null' assert_ok "verse defined" zsh -ic 'source $DOTFILES/config/animations.zsh; typeset -f verse >/dev/null' assert_ok "_git_welcome defined" zsh -ic 'source $DOTFILES/config/animations.zsh; typeset -f _git_welcome >/dev/null' assert_ok "_cross_fastfetch defined" zsh -ic 'source $DOTFILES/config/animations.zsh; typeset -f _cross_fastfetch >/dev/null' assert_ok "burst pair exported" zsh -ic 'source $DOTFILES/config/animations.zsh; [[ -n $CROSS_BURST ]]' # The burst ramp inverts on the wrong theme (its crest is the BRIGHTEST stop on # dark and the DEEPEST on dawn), and ricefx guesses from $COLORFGBG, which some # terminals set wrongly. This rice is base dark; pin it. assert_ok "ricefx pinned to dark" zsh -ic 'source $DOTFILES/config/animations.zsh; [[ $RICEFX_THEME == dark ]]' if [[ -x "$HOME/.local/bin/crossfetch" ]]; then assert_ok "crossfetch --logo works" "$HOME/.local/bin/crossfetch" --logo chi # Two accents must actually reach the flood — a regression to the one-hue # ramp is invisible in a smoke test but is the whole point of the mode. assert_ok "burst ramp is two-tone" python3 -c ' import sys, importlib.util from importlib.machinery import SourceFileLoader sys.path.insert(0, "'"$HOME"'/.local/bin") l = SourceFileLoader("cf", "'"$HOME"'/.local/bin/crossfetch") cf = importlib.util.module_from_spec(importlib.util.spec_from_loader("cf", l)) l.exec_module(cf); cf.use_burst_palette() a, b = cf.BURST_A, cf.BURST_B assert a != b, "both burst accents resolved to the same colour" assert cf.BURST_STOPS[0] != cf.BURST_STOPS[6], "ramp crests are identical" ' # The crest that sweeps the specs rewrites live ANSI, so it must put every # colour back exactly: the specs encode meaning (gold keys, love for a disk # at 81%) and an animation that permanently recoloured them would be # destroying information, not decorating it. assert_ok "sweep restores spec colours" python3 -c ' import sys, importlib.util from importlib.machinery import SourceFileLoader sys.path.insert(0, "'"$HOME"'/.local/bin") l = SourceFileLoader("cf", "'"$HOME"'/.local/bin/crossfetch") cf = importlib.util.module_from_spec(importlib.util.spec_from_loader("cf", l)) l.exec_module(cf) crest, mid = cf.fg((232, 213, 255)), cf.fg((196, 167, 231)) line = ("\x1b[1m\x1b[38;2;246;193;119m Disk\x1b[m\x1b[13G" "\x1b[38;2;224;222;244m371 GiB (\x1b[38;2;235;111;146m81%\x1b[m)") assert cf._sweep_line(line, 9999, crest, mid) == line, "crest absent must be a no-op" lit = cf._sweep_line(line, 20, crest, mid) assert crest in lit, "crest never applied" strip = lambda s: cf._ANSI.sub("", s) assert strip(lit) == strip(line), "sweep altered the text, not just its colour" assert lit.rstrip().endswith(")"), "sweep left an override hanging at EOL" ' # --fetch composes the columns itself; it must not hang without a tty, and # must emit the info it was handed rather than dropping it. () { local out out=$(printf 'OS\tmacOS\n' | "$HOME/.local/bin/crossfetch" --fetch 0 2>/dev/null) assert_ok "fetch emits piped info" test -n "$out" } fi # Even with splash toggles ON, a non-TTY stdout (this capture is a pipe) must # suppress the splash — proves the -t 1 guard protects scripts/perf. () { local out out=$(ANIM_SPLASH=1 CROSS_SPLASH=1 ZDOTDIR="$DOTFILES" zsh -ic 'source $DOTFILES/config/animations.zsh' 2>/dev/null) assert_eq "splash suppressed when stdout not a tty" "" "$out" }