#!/usr/bin/env zsh # ── animations.zsh : Chi-Rho fetch splash + on-demand animation ────────────── # Wraps the existing ~/.local/bin/crossfetch (animated orbiting-ring dashboard). # Splash runs only on a real interactive TTY, so it never blocks tests/scripts. export CROSS_MODE="${CROSS_MODE:-rose}" # crossfetch: rose | aurora | burst | ring | rain | both # rose = Rosé Pine rose window blooming open # around the symbol (stateless) # aurora = northern-lights arc + rays over a # star field, full poster rainbow (stateless) # burst = two-tone shockwave floods the terminal export CROSS_SPLASH="${CROSS_SPLASH:-1}" # 1 = animated splash on login export CROSS_TIMEOUT="${CROSS_TIMEOUT:-3}" # splash auto-exits after N sec (0 = until key) export ANIM_SPLASH="${ANIM_SPLASH:-1}" # master toggle for all startup eye-candy export SPLASH_STYLE="${SPLASH_STYLE:-silk}" # silk | cross | planet | none export SILK_MODE="${SILK_MODE:-bloom}" # silk: bloom | cross | silk | marble | ridge | loom | any | cycle # bloom = the 3D rose opening (login default since 2026-09-07) # cross = gold cross rising out of the dark (same renderer) # cycle = a different piece on every launch # CROSS_SYMBOL=chi|orthodox pins one symbol; unset = alternate per launch (☧/☦) # CROSS_BURST=gold,iris pins the burst pair; UNSET, crossfetch follows the # liturgical season (Advent purple, Lent purple, Eastertide gold...). export CROSS_GLOW="${CROSS_GLOW:-1.6}" # secs the fetch logo shimmers # in place after printing # (0 = off, any key skips) export CROSS_FPS="${CROSS_FPS:-60}" # frame ceiling for both # Pin the ramp. ricefx picks dawn/dark from $COLORFGBG, which some terminals # and multiplexers set to a light value regardless of the actual theme — and a # dawn ramp on this base-dark rice inverts every crest in the burst. export RICEFX_THEME="${RICEFX_THEME:-rose-pine}" # ── how much of the login wall to draw ─────────────────────────────────────── # The fastfetch dashboard is a fixed two-column layout, and the widths are # measured from the art rather than guessed: # # logo column 39 cols + 2 left + 6 right padding (config.jsonc) # box rail 54 cols ┌────Hardware────┐ # together 101 cols before anything has to give # wordmark 81 cols (/usr/share/omarchy/logo.txt) # # config.jsonc sets "disableLinewrap": true, so a terminal narrower than that # does NOT wrap the dashboard — it HARD-CUTS it. That is the squashed login you # get in a split or a dropdown: boxes with no right edge, values chopped # mid-word ("OS: Oma1", "Kernel: Lin2"). Rather than let it shred, each piece # is gated on the measured width and drops out in order: the logo column first # (the boxes alone are only 54 cols and stay intact), then the wordmark, then # the dashboard entirely — leaving the verse, which wraps on words. export SPLASH_FULL_COLS="${SPLASH_FULL_COLS:-101}" # under this: no logo column export SPLASH_BANNER_COLS="${SPLASH_BANNER_COLS:-81}" # under this: no wordmark export SPLASH_MIN_COLS="${SPLASH_MIN_COLS:-56}" # under this: no dashboard # Height matters as much as width and is the failure nobody names: the three # boxes are ~26 rows, the wordmark another 10, so in a short window the whole # splash simply scrolls off the top and all you are left with is the tail of a # box you never read. Under this many rows the dashboard stands down too. export SPLASH_MIN_ROWS="${SPLASH_MIN_ROWS:-30}" # under this: no dashboard # off | min | auto | full. $SPLASH_MODE beats the saved choice beats auto, so a # one-off `SPLASH_MODE=off kitty` never overwrites what `splash off` recorded. _SPLASH_MODE_FILE="$HOME/.config/crossfetch/splash-mode" # zsh keeps $COLUMNS current across SIGWINCH but does not export it. Exporting # makes the live width visible to children — which is how the prompt's netspeed # module knows to stand down before it pushes the right rail off a narrow # terminal, and how a resize is honoured on the very next prompt. export COLUMNS _ANIM_DIR="${ZDOTDIR:-$HOME/.dotfiles}/scripts" _splash_cols() { local -i c=${COLUMNS:-0} (( c > 0 )) || c=$(tput cols 2>/dev/null) (( c > 0 )) || c=80 print -r -- $c } _splash_rows() { local -i r=${LINES:-0} (( r > 0 )) || r=$(tput lines 2>/dev/null) (( r > 0 )) || r=24 print -r -- $r } _splash_mode() { local m=${SPLASH_MODE:-} [[ -z $m && -r $_SPLASH_MODE_FILE ]] && m="$(<$_SPLASH_MODE_FILE)" case $m in (off|min|auto|full) print -r -- $m ;; (*) print -r -- auto ;; esac } # Resolve the mode against the live width into four globals rather than a # printed string: the startup path and `splash` both need all four, and this # runs on every login. # _SPLASH_FETCH full | compact | off compact = the boxes, no logo column # _SPLASH_BANNER on | off the Omarchy wordmark # _SPLASH_ANIM on | off the crossfetch/planet animation # _SPLASH_TEXT on | off daily verse + git welcome typeset -g _SPLASH_FETCH _SPLASH_BANNER _SPLASH_ANIM _SPLASH_TEXT _splash_plan() { local -i c=$(_splash_cols) r=$(_splash_rows) case "$(_splash_mode)" in off) _SPLASH_FETCH=off _SPLASH_BANNER=off _SPLASH_ANIM=off _SPLASH_TEXT=off ;; min) _SPLASH_FETCH=off _SPLASH_BANNER=off _SPLASH_ANIM=off _SPLASH_TEXT=on ;; full) _SPLASH_FETCH=full _SPLASH_BANNER=on _SPLASH_ANIM=on _SPLASH_TEXT=on ;; *) if (( r < SPLASH_MIN_ROWS )); then _SPLASH_FETCH=off elif (( c >= SPLASH_FULL_COLS )); then _SPLASH_FETCH=full elif (( c >= SPLASH_MIN_COLS )); then _SPLASH_FETCH=compact else _SPLASH_FETCH=off ; fi # The wordmark only earns its 10 rows next to a dashboard that fits. [[ $_SPLASH_FETCH != off ]] && (( c >= SPLASH_BANNER_COLS )) \ && _SPLASH_BANNER=on || _SPLASH_BANNER=off (( c >= SPLASH_MIN_COLS )) && _SPLASH_ANIM=on || _SPLASH_ANIM=off _SPLASH_TEXT=on ;; esac } # silk [mode] [secs] -> ~/.local/bin/silk: bloom | cross | silk | marble | ridge | loom | any | cycle # (0/empty secs = until keypress) silk() { [[ -x "$HOME/.local/bin/silk" ]] && CROSS_TIMEOUT=0 "$HOME/.local/bin/silk" "$@"; } silkmode() { export SILK_MODE="$1"; print -r -- "SILK_MODE=$SILK_MODE"; } # planet [secs] -> rotating planet + ring + moon (0/empty = until keypress) planet() { [[ -r "$_ANIM_DIR/planet.zsh" ]] && zsh "$_ANIM_DIR/planet.zsh" "${1:-0}"; } # fastfetch with the logo matching the current CROSS_SYMBOL, and — on a real # TTY — the logo left shimmering in place for a moment after the specs land. # # crossfetch composes the two columns itself in this path rather than letting # fastfetch draw the logo, because animating the art afterwards means knowing # exactly which rows and columns it occupies. fastfetch is piped INTO it (not # run by it) so that it still reports the real Shell and Terminal: it names # those by walking up the process tree, and as crossfetch's child it would # answer "crossfetch" and "Python". _cross_fastfetch() { (( $+commands[fastfetch] )) || return # Width gate before every other branch, because every other branch draws a # logo column of some kind and the logo column is exactly what does not fit. # `--logo none` is the whole of "compact": the box rail is 54 columns and # renders intact on its own, so the narrow login loses the art and keeps all # the information — which is the right way round. local tier=${1:-} [[ -n $tier ]] || { _splash_plan; tier=$_SPLASH_FETCH } case $tier in (off) return ;; (compact) fastfetch --logo none; return ;; esac # CROSS_FETCH=omarchy: run Omarchy's own fastfetch config untouched. It draws # its own logo, so passing --logo here would override it. Unset (or set to # anything else) to go back to the crossfetch/rotating-logo behaviour below. # CROSS_FETCH=plain (NixDaemon): bare fastfetch too; the Nix-managed # ~/.config/fastfetch/config.jsonc draws its own logo (the NixOS snowflake). if [[ ${CROSS_FETCH:-} == (omarchy|plain) ]]; then fastfetch; return; fi # arch/omarchy are FILE logos: crossfetch's SYMBOLS table has no mask for # them and an unknown name silently renders the Chi-Rho (rc=0), so they must # never reach `crossfetch --fetch`. They take the file-raw branch below, # where fastfetch draws the art and measures the column offset itself. if [[ -x "$HOME/.local/bin/crossfetch" && -t 1 ]] && ! _cross_is_file_logo; then fastfetch --logo none --pipe false | "$HOME/.local/bin/crossfetch" --fetch return fi local logo="$(_cross_art_dir)/${CROSS_SYMBOL:-chi}.txt" # Hand-made art (arch.txt, glider.txt, ...) still sits beside the config. [[ -r "$logo" ]] || logo="$HOME/.config/fastfetch/${CROSS_SYMBOL:-chi}.txt" if [[ -r "$logo" ]]; then fastfetch --logo-type file-raw --logo "$logo" else fastfetch; fi } # True when ~/.config/fastfetch belongs to home-manager, which links it (or the # config.jsonc inside it) into /nix/store. On NixDaemon programs.fastfetch owns # the file (modules/home/prompt.nix): crossfetch's os.replace() would clobber # the managed link, and then `nh os switch` fails for good — home-manager wants # to back the stray file up, the backup collides with an older # config.jsonc.hm-bak, and activation aborts in checkLinkTargets. The writes # also land in the dotfiles checkout through the link, dirtying the repo. _cross_nix_fastfetch() { local d="$HOME/.config/fastfetch" [[ -L "$d" && "$(readlink -- "$d")" == /nix/store/* ]] && return 0 [[ -L "$d/config.jsonc" && "$(readlink -- "$d/config.jsonc")" == /nix/store/* ]] } # Where generated art may be written: beside the config where that directory is # ours (Omarchy — its config.jsonc sources cross.txt from there), under state # where Nix owns it (and the directory is read-only anyway). _cross_art_dir() { if _cross_nix_fastfetch; then print -r -- "$HOME/.local/state/crossfetch/logos" else print -r -- "$HOME/.config/fastfetch" fi } # Regenerate the fastfetch logos + themed config whenever the day or the # theme changed — keeps the static cross.txt tracking the liturgical season. _cross_regen() { local dir="$HOME/.local/state/crossfetch" local marker="$dir/last-render" local want="$(date +%F) ${RICEFX_THEME:-dark}" local have="" [[ -r "$marker" ]] && have="$(<"$marker")" [[ "$have" == "$want" ]] && return local art="$(_cross_art_dir)" mkdir -p "$dir" "$art" local cf="$HOME/.local/bin/crossfetch" s [[ -x "$cf" ]] || return # NEVER add arch/omarchy here: `crossfetch --logo arch` writes the CHI-RHO # (unknown names fall back silently, rc=0), so it would both clobber the # hand-generated art and replace it with the wrong logo. for s in chi orthodox jerusalem ichthys kali skull; do "$cf" --logo "$s" > "$art/$s.txt" 2>/dev/null done "$cf" --logo > "$art/cross.txt" 2>/dev/null # Never render config.jsonc over a Nix-managed file (see _cross_nix_fastfetch). # CROSS_FETCH=plain, which NixDaemon uses, ignores these accents anyway. _cross_nix_fastfetch || "$cf" --sync-fastfetch 2>/dev/null print -r -- "$want" >| "$marker" 2>/dev/null } [[ -o interactive ]] && _cross_regen # cross [mode] -> crossfetch orbiting-ring dashboard, until a key is pressed cross() { # The burst/ring animation also reads CROSS_SYMBOL, so a file logo would # animate a silent Chi-Rho. Substitute a real mask for THIS command only — # the exported CROSS_SYMBOL (prompt glyph, panel logo) stays arch/omarchy. [[ -x "$HOME/.local/bin/crossfetch" ]] && CROSS_TIMEOUT=0 \ CROSS_SYMBOL="${_CROSS_ANIM_FALLBACK[$CROSS_SYMBOL]:-$CROSS_SYMBOL}" \ "$HOME/.local/bin/crossfetch" "${1:-$CROSS_MODE}" (( $+commands[fastfetch] )) && _cross_fastfetch } crossmode() { export CROSS_MODE="$1"; print -r -- "CROSS_MODE=$CROSS_MODE"; } crosssym() { export CROSS_SYMBOL="$1"; print -r -- "CROSS_SYMBOL=$CROSS_SYMBOL"; } # daily verse (offline, rotates by day-of-year) # # Wrapped on word boundaries rather than left to the terminal, which breaks # mid-word. The verse is the one piece of the splash that survives a narrow # pane — it has to look deliberate there, not truncated. verse() { local f=~/.config/crossfetch/verses.txt [[ -r $f ]] || return local -a vs; vs=("${(@f)$(grep -ve '^[[:space:]]*$' $f)}") (( ${#vs} )) || return local doy=$((10#$(date +%j))) local line="${vs[$(( doy % ${#vs} + 1 ))]}" local text="${line% — *}" who="${line##* — }" local -i cols=$(_splash_cols) # 3 columns of indent each side, plus " — " before the attribution. if (( ${#text} + ${#who} + 10 <= cols )); then print -P "%F{#908caa} ${text}%f %F{#ebbcba}— ${who}%f" return fi local -i width=$(( cols - 6 )) (( width < 16 )) && width=$(( cols > 4 ? cols - 2 : cols )) local -a words out; words=(${=text}) local cur="" w for w in $words; do if [[ -z $cur ]]; then cur=$w elif (( ${#cur} + 1 + ${#w} <= width )); then cur+=" $w" else out+=("$cur"); cur=$w; fi done [[ -n $cur ]] && out+=("$cur") for w in $out; do print -P "%F{#908caa} ${w}%f"; done print -P "%F{#ebbcba} — ${who}%f" } # context-aware welcome: inside a git repo, show a compact dashboard _git_welcome() { (( $+commands[git] )) || return git rev-parse --is-inside-work-tree >/dev/null 2>&1 || return local br dirty br=$(git symbolic-ref --short HEAD 2>/dev/null || git rev-parse --short HEAD 2>/dev/null) dirty=$(git status --porcelain 2>/dev/null | grep -c .) print -P "%F{#9ccfd8} ── repo%f %F{#eb6f92}%f %F{#f6c177}${br}%f %F{#908caa}${dirty} changed%f" git --no-pager log --oneline -3 --color=always 2>/dev/null | sed 's/^/ /' } # Symbol selection runs on EVERY interactive shell (independent of the splash), # so the starship prompt glyph always matches. Rotates per launch through the # whole crossfetch set — crosses and hacker marks. Pre-set CROSS_SYMBOL to pin. _CROSS_CYCLE=(chi orthodox jerusalem ichthys kali skull arch omarchy nixos) # Appended, never inserted: every cached value keeps its successor, so # ~/.cache/crossfetch/symbol needs no migration. # Symbols crossfetch cannot draw — fastfetch renders these from a .txt file. # Static art, hand-generated, deliberately NOT in _cross_regen's loop. _CROSS_FILE_LOGOS=(arch omarchy nixos) # Mask crossfetch animates while a file logo is showing. typeset -gA _CROSS_ANIM_FALLBACK=(arch chi omarchy orthodox nixos chi) # (Ie) = index of last exact match, 0 when absent — the opposite of (ie), # which returns len+1 when absent and would make every non-member test true. _cross_is_file_logo() { (( ${_CROSS_FILE_LOGOS[(Ie)${1:-$CROSS_SYMBOL}]} )) } # Keep bare `fastfetch` and the Omarchy About window in step with the # rotation. config.jsonc is generated from a shared template, so its logo # source stays the fixed path cross.txt and we swap the CONTENT instead. # cp, never `ln -s`: _cross_regen writes cross.txt with `>`, which follows a # symlink and would overwrite arch.txt itself. _cross_sync_panel() { local d="$HOME/.config/fastfetch" src src="$d/${CROSS_SYMBOL:-chi}.txt" [[ -r "$src" ]] || return # symbol with no .txt: leave cross.txt alone command cp -f -- "$src" "$d/.cross.$$.tmp" 2>/dev/null && command mv -f -- "$d/.cross.$$.tmp" "$d/cross.txt" 2>/dev/null || command rm -f -- "$d/.cross.$$.tmp" 2>/dev/null } if [[ -o interactive ]]; then if [[ -z "$CROSS_SYMBOL" ]]; then _cross_state="$HOME/.cache/crossfetch/symbol" _cross_prev="$(<$_cross_state)" 2>/dev/null _cross_i=${_CROSS_CYCLE[(ie)$_cross_prev]} # index of prev (len+1 if absent) export CROSS_SYMBOL="${_CROSS_CYCLE[$(( _cross_i % ${#_CROSS_CYCLE} + 1 ))]}" command mkdir -p "${_cross_state:h}" 2>/dev/null print -r -- "$CROSS_SYMBOL" >| "$_cross_state" 2>/dev/null unset _cross_state _cross_prev _cross_i fi # Glyph for the prompt (starship reads $CROSS_GLYPH via env_var). # # The three Nerd Font glyphs are written as \U escapes rather than pasted # literally. They were literals before and all three arrived here as EMPTY # STRINGS — a paste through something that dropped astral-plane characters — # so kali, ichthys and skull silently rendered nothing at all in the prompt. # An escape survives that, and it also says which glyph is meant. # # Codepoints verified present in the installed Nerd Font faces; kitty falls # back per glyph, so they resolve even though the configured font_family is # not the one supplying them. case "$CROSS_SYMBOL" in orthodox) export CROSS_GLYPH="☦" ;; jerusalem) export CROSS_GLYPH="╬" ;; ichthys) export CROSS_GLYPH=$'\U0F0195' ;; # nf-md-fish kali) export CROSS_GLYPH=$'\U00F327' ;; # nf-linux-kali_linux skull) export CROSS_GLYPH=$'\U0F068C' ;; # nf-md-skull # The Chi-Rho stays on the prompt even on arch days — ☧ first, then the # Arch logo. starship styles the whole $CROSS_GLYPH value as one span. arch) export CROSS_GLYPH="☧ "$'\U00F303' ;; # ☧ + nf-linux-archlinux # NixOS (2026-10-08, the NixDaemon machine): same shape, the snowflake. # ~/.config/fastfetch/nixos.txt is fastfetch's builtin nixos logo in Rosé # Pine iris/foam, 45 columns wide (arch is 39), so the pinned .zshrc also # raises SPLASH_FULL_COLS. nixos) export CROSS_GLYPH="☧ "$'\U00F313' ;; # ☧ + nf-linux-nixos # U+E900 is the Omarchy brand mark, but it lives ONLY in the `omarchy` # font family -- JetBrainsMono NF has no such codepoint, so the terminal # fell back to a different face for that one cell, and the mark is a square # outline that reads as tofu at prompt size. U+F17C is native to JBM NF. omarchy) export CROSS_GLYPH=$'\U00F17C' ;; # nf-fa-linux (tux) *) export CROSS_GLYPH="☧" ;; esac # Runs OUTSIDE the `[[ -z $CROSS_SYMBOL ]]` guard so a pinned symbol syncs too. _cross_sync_panel fi # Omarchy wordmark banner. `omarchy show logo` prints the same art but hardcodes # green and calls `clear` first, which would wipe scrollback on every new # terminal -- so read the art directly and tint it to the Rosé Pine ramp. # Set OMARCHY_BANNER=0 to turn it off. _omarchy_banner() { [[ ${OMARCHY_BANNER:-1} == 1 ]] || return local art="${OMARCHY_PATH:-/usr/share/omarchy}/logo.txt" # On a machine without the Omarchy wordmark (macOS, or a bare Linux box) fall # back to the DAEMON-SEC banner shipped in the dotfiles. On Omarchy the # logo.txt is present, so that box shows the Omarchy wordmark unchanged — the # DAEMON-SEC banner never appears there. [[ -r $art ]] || art="$HOME/.config/crossfetch/daemon-sec.txt" [[ -r $art ]] || return local -a lines; lines=("${(@f)$(<$art)}") (( $#lines )) || return # foam -> iris down the wordmark, matching the bar and prompt accents. local -a from to; from=(156 207 216); to=(196 167 231) local i n r g b n=$(( $#lines > 1 ? $#lines - 1 : 1 )) for i in {1..$#lines}; do r=$(( from[1] + (to[1]-from[1]) * (i-1) / n )) g=$(( from[2] + (to[2]-from[2]) * (i-1) / n )) b=$(( from[3] + (to[3]-from[3]) * (i-1) / n )) printf '\033[38;2;%d;%d;%dm%s\033[0m\n' $r $g $b "${lines[i]}" done print } # ── splash [off|min|auto|full|now|status] ──────────────────────────────────── # One switch over the whole login wall, remembered across shells. # # auto (default) draw whatever fits the terminal, drop the rest # full draw everything regardless — for a maximised window # min verse and git welcome only # off nothing; a bare prompt # # The mode is the ceiling, not an override: `auto` still measures, `full` still # obeys ANIM_SPLASH/CROSS_SPLASH. splash() { local a="${1:-status}" case $a in (off|min|auto|full) command mkdir -p "${_SPLASH_MODE_FILE:h}" 2>/dev/null print -r -- "$a" >| "$_SPLASH_MODE_FILE" 2>/dev/null || { print -u2 -r -- "splash: cannot write $_SPLASH_MODE_FILE"; return 1 } unset SPLASH_MODE # a stale env pin would silently outrank this print -P "%F{#c4a7e7}❀%f splash %F{#908caa}→%f %F{#f6c177}$a%f" ;; (now|show) # Asked for explicitly, so draw it — sized to the window, but not # suppressed by a saved `off`/`min`, which is about the LOGIN wall. local SPLASH_MODE=auto _splash_plan [[ $_SPLASH_BANNER == on ]] && _omarchy_banner _cross_fastfetch "$_SPLASH_FETCH" verse; _git_welcome ;; (status) _splash_plan local -i c=$(_splash_cols) print -P "%F{#c4a7e7}❀%f splash %F{#f6c177}$(_splash_mode)%f %F{#6e6a86}·%f ${c}×$(_splash_rows)" print -P " %F{#908caa}dashboard%f $_SPLASH_FETCH %F{#6e6a86}(logo ≥${SPLASH_FULL_COLS} cols, boxes ≥${SPLASH_MIN_COLS} cols, both ≥${SPLASH_MIN_ROWS} rows)%f" print -P " %F{#908caa}wordmark %f $_SPLASH_BANNER %F{#6e6a86}(≥${SPLASH_BANNER_COLS})%f" print -P " %F{#908caa}animation%f $_SPLASH_ANIM" print -P " %F{#908caa}verse %f $_SPLASH_TEXT" print -P "%F{#6e6a86} splash off|min|auto|full · splash now to redraw here%f" ;; (-h|--help) print -r -- 'usage: splash [off|min|auto|full|now|status]' ;; (*) print -u2 -r -- "splash: unknown mode: $a (try: off min auto full now status)" return 2 ;; esac } # startup splash — only on a real interactive TTY, bounded + skippable, and # only as much of it as the terminal can actually hold. if [[ -o interactive && -t 1 && "$ANIM_SPLASH" == 1 && "$CROSS_SPLASH" == 1 ]]; then _splash_plan if [[ $_SPLASH_ANIM == on ]]; then case "$SPLASH_STYLE" in silk) [[ -x "$HOME/.local/bin/silk" ]] && "$HOME/.local/bin/silk" "$SILK_MODE" ;; planet) planet "$CROSS_TIMEOUT" ;; cross) [[ -x "$HOME/.local/bin/crossfetch" ]] && \ CROSS_SYMBOL="${_CROSS_ANIM_FALLBACK[$CROSS_SYMBOL]:-$CROSS_SYMBOL}" \ "$HOME/.local/bin/crossfetch" "$CROSS_MODE" ;; none) ;; esac fi [[ $_SPLASH_BANNER == on ]] && _omarchy_banner (( $+commands[fastfetch] )) && _cross_fastfetch "$_SPLASH_FETCH" [[ $_SPLASH_TEXT == on ]] && { verse; _git_welcome } fi