Set up your MacBook to play funny sound clips whenever it detects a hard knock or slap using its built-in accelerometer
Use custom MP3 files by pointing the program at your own audio folder instead of the built-in clips
Install as a background launch service so it starts automatically on login without opening a terminal
Tune the impact threshold and cooldown to avoid triggering on minor bumps during everyday use
Requires an M2 or M1 Pro MacBook and administrator privileges to read the hardware accelerometer via IOKit.
Spank is a small joke program for Apple Silicon MacBooks that plays sound effects when you physically slap the laptop. It reads data from the motion sensor built into certain Mac models and, when it detects a sharp impact, plays an audio clip in response. The default mode plays one of ten pain or protest sound clips at random when a hit is detected. A "sexy mode" tracks slap frequency over a rolling five-minute window and escalates the audio response the more you hit the laptop. A Halo mode plays death sound effects from the Halo video game series. A custom mode lets you point it at a folder of MP3 files and it will play those instead. The detection can be tuned with a few settings. You can adjust the minimum acceleration threshold that counts as a hit, set a cooldown time between sounds to avoid rapid firing, control the polling speed, and change the playback speed and pitch of the audio clips. The program requires a MacBook with an M2 chip or higher, or the specific M1 Pro model. It uses a low-level Apple hardware interface called IOKit HID to read the accelerometer directly, which is why it needs administrator privileges to run. Once installed, it can also be set up as a background service so it starts automatically at boot. Spank is a single binary with no external dependencies, built in Go and released under the MIT license. It is openly described as a fun project rather than a serious tool.
← taigrr on gitmyhub — every repo by this author, as a profile.
Verify against the repo before relying on details.