Skip to content

Sandman

Sandman logo

After midnight

I do my best thinking between 9:30 and 11pm. Something about the quiet, the lack of interruptions — the ideas just come faster. I’ve shipped more features in that window than I care to admit.

But I also know the research. I’ve read the papers. Screen light at night wrecks your sleep, and wrecked sleep makes you dumber the next day. So I’m caught: stop working when my brain is on fire, or pay for it tomorrow.

Night Shift doesn’t fix this. I tried it for months and still felt wired past midnight. Turns out there’s a reason — it doesn’t cut nearly enough blue light. So I built something that does.

The science

Behind the rods and cones that form images, a sparse network of retinal ganglion cells (ipRGCs) wire directly to the brain’s master clock, the suprachiasmatic nucleus. These cells contain melanopsin, a photopigment that peaks at ~480 nm. Blue light.

When melanopsin fires, it signals daytime. Melatonin shuts down. The circadian clock phase-shifts forward. You stay alert.

Every LED-backlit screen emits a spectral spike at 450-460 nm, right at melanopsin’s peak sensitivity. Brainard et al. (2001) measured peak melatonin suppression at 446-477 nm. Chang et al. (2015) found that 4 hours of iPad use before bed delayed melatonin onset by over 90 minutes and reduced next-morning alertness.

Why red

Red works because three things happen at once.

Melanopsin’s sensitivity drops to near zero above 600 nm. Red light (620-750 nm) doesn’t trigger the circadian pathway at all. Software “night shift” modes cut blue emission by 30-50%, which still leaves enough short-wavelength light to suppress melatonin. Patrick Mineault measured this directly with a colorimeter: Apple’s Night Shift reduces melanopsin-relevant light by about half.

Halving light is a tiny blip of the dynamic range of vision. The real lever is total luminance, not color.

His conclusion: blue light filters don’t work. What does work is eliminating short wavelengths entirely, which is what Sandman does — it zeros out everything below red.

Rod cells contain rhodopsin, which peaks at ~498 nm. Red barely registers. This is why astronomers and submariners have used red lighting for decades: it preserves dark adaptation. Rhodopsin stays unbleached, so when you look away from the screen, you can still see in the dark.

L-cones peak at ~560 nm but remain sensitive out to ~700 nm. Red gives you enough to read a screen. You lose color (everything’s red) but you keep spatial acuity and contrast.

Net effect: you can use your computer at night without telling your brain it’s noon.

What Sandman does

Sandman in action

Sandman writes directly to your display’s gamma lookup tables, zeroing the blue and green channels. Only red passes through.

Not a software overlay. The filter runs at the display controller level — zero CPU overhead while active. Screenshots and screen recordings capture full-color output because the filter sits below the framebuffer. Invisible to everything except your eyes.

PlatformInterfaceBackend
macOSMenu bar appCoreGraphics CGSetDisplayTransferByTable
LinuxCLIX11 (XRandR) / Wayland (wlr-gamma-control)
WindowsCLIGDI SetDeviceGammaRamp

Scheduling is automatic: activates at sunset, deactivates at sunrise, calculated from your timezone (no location permission needed). The schedule thread computes the exact duration until the next transition and sleeps until then — no polling. Handles display hotplug, applies to all connected monitors. Restores original gamma tables on quit, crash, or signal.

Rust core. Thin Swift/AppKit shell for the macOS menu bar. Pure CLI on Linux and Windows.

Get it

macOSDownload Sandman (macOS 14+, Apple Silicon, ~3.5 MB)

LinuxDownload binary or .deb package (amd64)

WindowsDownload sandman.exe (amd64)

sandman on       # red-only filter, immediate
sandman off      # restore original gamma
sandman daemon   # sunset/sunrise scheduling

Keyboard Shortcuts