Spank is a fun utility that detects physical impacts on Apple Silicon MacBooks via the built-in accelerometer and plays audio responses.
The tool solves the problem of making your laptop interactive through physical interaction. It reads raw accelerometer data directly from the Bosch BMI286 IMU via IOKit HID, then applies vibration detection algorithms including STA/LTA analysis, CUSUM, kurtosis, and peak/MAD calculations to identify when the laptop has been struck. When a significant impact is detected, it plays one of several embedded MP3 audio responses depending on the selected mode. The tool includes optional volume scaling so lighter taps produce quieter responses and harder slaps play at full volume, plus adjustable playback speed control.
Spank is designed purely for entertainment and novelty use on Apple Silicon Macs running M2 or later chips, or the M1 Pro specifically. It requires sudo access to read from the accelerometer and runs as a single binary with no external dependencies. The tool offers multiple modes: Pain mode plays random protest audio clips, Sexy mode tracks cumulative slaps within a rolling window and escalates through 60 intensity levels, Halo mode plays death sound effects from the Halo video game series, and Custom mode lets you specify your own MP3 directory. Detection sensitivity is tunable through amplitude thresholds and cooldown periods, with a fast mode preset available for more responsive detection.
The project maintains a focused scope with straightforward implementation. Development activity shows regular refinement of the detection algorithms and user-facing tuning options, with attention paid to making the tool easy to install and run as a background service via launchd. The codebase remains minimal and self-contained, avoiding external dependencies while directly interfacing with macOS system APIs.