Why it exists
The good ones already exist. Finding them is the afternoon you lose.
cmatrix, pipes.sh, asciiquarium: each does one thing well, each has its own flags, its own colour handling, and its own idea of which key quits. Remembering which is which is the actual cost.
afk puts a coherent set behind one command, gives all of them the same themes, the same controls and the same quit behaviour, and runs the classics directly rather than reimplementing them badly. Every effect names the prior art it is built on, and a test fails when one of those credits goes missing.
The thirty
All of them. Pick one and it runs in the window.
$ afk fire
The part that took the work
Drawing it is cheap. Getting it to your terminal is not.
Every effect fills a buffer twice as tall as the terminal has rows, and one character cell then shows two stacked pixels drawn as the upper half block. Free vertical resolution, and also where the problem starts: a full repaint of a 200 by 50 window in 24-bit colour is about 300 KB per frame, which is 9 MB a second at 30fps, and your terminal emulator parses every byte.
So the renderer keeps the last frame and emits only the cells that changed. Measured at 200 by 50:
| effect | generate | on the wire | relative |
|---|---|---|---|
| clock | 1.7 ms | ~0 KB | |
| glyphs | 1.7 ms | 0.6 KB | |
| rain | 1.5 ms | 1.0 KB | |
| fire | 4.4 ms | 27 KB | |
| plasma | 8.1 ms | 289 KB |
afk doctor measures both numbers on your own terminal and tells
you which side of that line you are on.
Getting it
Python 3.9 or newer, and a terminal. That is the whole list.
Install
The package is afk-term because afk was taken. The command it installs is afk.
$ pip install afk-term
Run it
No arguments picks a random effect. Any key brings you back.
$ afk
Pick one, or theme it
Name an effect, apply one of twelve palettes, or rotate through everything with afk cycle.
$ afk --theme dracula lava
Let it start itself
A real idle hook on zsh. On any other shell afk shell-init tmux prints the tmux recipe instead of pretending the two are the same feature.
$ afk install-idle zsh --seconds 300
Standing on
Almost none of this is a new idea, and the code says so.
- fire the PSX Doom routine, via Fabien Sanglard
- rain, glyphs cmatrix, Chris Allegretta
- stars the Windows 3.1 starfield
- plasma, tunnel demoscene, Amiga and DOS
- lava Jim Blinn's blobby models, 1982
- life John Conway, 1970
- boids Craig Reynolds, 1986
- maze XScreenSaver, Randell and Zawinski
- mandelbrot Benoit Mandelbrot
- snow xsnow, Rick Jansen
- pong Atari, 1972
- sort Timo Bingmann's sound-of-sorting
- clock tty-clock, Martin Duquesnoy
- pipes, aquarium pipes.sh and asciiquarium, run directly