Skip to content

cuberact/matrix-digital-rain

Repository files navigation

Matrix Digital Rain

Matrix Digital Rain

A native macOS screensaver of the classic "digital rain" from The Matrix, written in Swift and Metal. It is a faithful re-implementation of the wonderful rezmason/matrix web effect, but built to run cold: at its default 10 fps it lets the GPU fall asleep between frames instead of pegging it like a typical screensaver.

Screensaver GPU power (two displays)
Matrix Digital Rain (this, 10 fps) ~1.6 W
Apple "Drift" (built into macOS) ~5.1 W
rezmason/matrix via WebViewScreenSaver ~6.2 W

Why this exists

I wanted that gorgeous rezmason digital rain running as a real screensaver across both of my monitors. The easy way is WebViewScreenSaver, which shows any web page as a screensaver, so I pointed it at the rezmason demo. It looked perfect.

One problem: it cooked my MacBook. The effect is heavy in a browser canvas, and the webview wrapper recomposites the page on every single vsync no matter what frame rate the page asks for, so the GPU never gets to rest. On two displays it pulled about 6.2 W of GPU power continuously and the fans spun up. A screensaver that saves the display but bakes the laptop is not a great trade.

So I had it rewritten natively in Metal. Same look, but rendered at a low frame rate where the GPU can actually go idle between frames. The full effect on both displays now draws around 1.6 W. Apple's own built-in "Drift" screensaver pulls about 5.1 W on the same machine, so this ends up roughly 3x more efficient than what ships with macOS, and nearly 4x better than the webview approach.

What was hard

Two parts.

Porting the effect. The rain is a faithful port of rezmason/matrix: the falling-brightness simulation and the glyph cycling run as small ping-pong passes, the glyphs are drawn from an MSDF atlas, and there is a five level bloom pyramid plus a palette and dither pass, all reimplemented in Metal Shading Language. The big power trick is simply rendering at 10 fps through a CADisplayLink so the GPU sleeps in between.

The macOS screensaver lifecycle, which is genuinely broken on recent macOS. On macOS 14 and later, stopAnimation is no longer called for the real screensaver, no stop notifications fire, dismissed instances keep rendering in the background, and instances pile up. occlusionState and isPreview both lie, so none of the documented ways to know "am I actually on screen" work. The fix that finally held is to read the context from the frontmost application: the real screensaver runs under loginwindow, the System Settings preview under System Settings, and anything else means this is a leaked background instance that should render nothing and quit. That signal was found by instrumenting the sandboxed screensaver process to dump its window state to a file, because logging does not surface from that host either. The system color panel is broken in the same host as well (it refuses to reopen), so the color picker is built from plain inline sliders instead.

If you want the gory details, the code comments tell the story.

Features

  • The faithful Matrix "classic" look (rezmason's "matrixcode" glyphs)
  • Runs cold: about 1.6 W on two displays at 10 fps
  • Configurable from the screensaver Options panel: color (hue) and brightness, columns, fall speed, animation speed, glyph cycle speed, raindrop length, cursor intensity, bloom size and strength, dither, FPS, and render resolution
  • Universal binary (Apple Silicon and Intel)

Build and install

You need macOS 14 (Sonoma) or later with Xcode. It was developed and tested on macOS 26 (Tahoe).

  1. Clone this repository.
  2. Open MatrixDigitalRain.xcodeproj in Xcode.
  3. Build it (Cmd+B). The product is MatrixDigitalRain.saver.
  4. Double-click the built .saver to install it, or copy it into ~/Library/Screen Savers/.
  5. Choose "Matrix Digital Rain" in System Settings, Screen Saver.

The build is ad-hoc signed for local use. If macOS blocks it, allow it under System Settings, Privacy and Security.

A note on who wrote this

I am not going to hide it: the entire thing, the Metal port, the Swift app, and all of the macOS lifecycle archaeology, was written by Claude, Anthropic's coding agent (Claude Code, running Opus). I had the idea, directed the work, and did the testing and power measurements on my own hardware. Claude wrote the code.

Credits and license

  • The original effect, the look, and the glyph atlas all come from rezmason/matrix. This project is a native re-implementation of that, nothing more clever.
  • Released under the MIT license, see LICENSE. rezmason/matrix is also MIT licensed.

Contributors

Languages