DEV Community

Cover image for I built a terminal screensaver in Go — constellations, rain, braille waves, and full shell integration
phlx0
phlx0

Posted on

I built a terminal screensaver in Go — constellations, rain, braille waves, and full shell integration

Every OS has a screensaver. The terminal had nothing.

So I built drift — a terminal screensaver written in Go that activates automatically when your shell goes idle and disappears the moment you press any key.

https://github.com/phlx0/drift


How it works

drift is built on tcell and renders directly to the terminal at a configurable frame rate (default 30fps). Each scene is its own self-contained animation loop that fills the full terminal dimensions and reacts to resize events.

The shell integration is the core feature. When you source the init snippet, your shell installs a hook that measures inactivity time. After the configured timeout (default 120 seconds), drift launches in place. Press any key and you're back at your prompt — no intermediate screens, no delay.

# Zsh
export DRIFT_TIMEOUT=120
eval "$(drift shell-init zsh)"

# Bash
eval "$(drift shell-init bash)"

# Fish
drift shell-init fish | source
Enter fullscreen mode Exit fullscreen mode

Scenes

drift ships four animations that cycle automatically or can be locked with --scene:

waveform — braille Unicode sine waves rendered in layers that breathe and shift phase over time. Three overlapping wave layers create a depth effect that's surprisingly hypnotic.

constellation — stars drift slowly across the terminal and draw edges between neighbors within a configurable connection radius. Star count, twinkle, and max connections per node are all tunable.

rain — katakana characters fall in columns, matrix-style. The charset, density, and fall speed are configurable.

particles — a flow field of glyphs with configurable gravity, friction, and count. Each particle follows a noise-driven vector field.

Scenes cycle on a configurable interval (--duration, default 60s) with shuffle support.


Themes

Seven built-in themes matched to popular terminal colorschemes:

cosmic · nord · dracula · catppuccin · gruvbox · forest · mono

drift list themes    # preview all themes with color swatches
Enter fullscreen mode Exit fullscreen mode

Configuration

All settings live in ~/.config/drift/config.toml. Running drift config --init writes the default file so you have something to edit from.

[engine]
fps           = 30
cycle_seconds = 60
scenes        = "all"
theme         = "cosmic"
shuffle       = true

[scene.constellation]
star_count      = 80
connect_radius  = 0.18
twinkle         = true
max_connections = 4

[scene.rain]
charset = "アイウエオカキクケコサシスセソタチツテトナニヌネノ0123456789"
density = 0.4
speed   = 1.0

[scene.particles]
count    = 120
gravity  = 0.0
friction = 0.98

[scene.waveform]
layers    = 3
amplitude = 0.70
speed     = 1.0
Enter fullscreen mode Exit fullscreen mode

Install

No Go required if you just want the binary:

# macOS Apple Silicon
curl -L https://github.com/phlx0/drift/releases/latest/download/drift_darwin_arm64.tar.gz | tar xz
sudo mv drift /usr/local/bin/

# Or via go install
go install github.com/phlx0/drift@latest
Enter fullscreen mode Exit fullscreen mode

Pre-built binaries for macOS (arm64/amd64) and Linux (amd64/arm64) on the releases page. No CGO, no C compiler needed.


Why Go?

I normally reach for Python for terminal tools (I also built snip in Python + Textual). For drift I wanted a single static binary with no runtime dependency, sub-millisecond render loops, and direct terminal control without a framework abstracting the raw bytes. Go + tcell was the right fit.


Feedback welcome, especially if you have ideas for new scenes or themes.

Source: https://github.com/phlx0/drift

Top comments (0)