explaingit

taigrr/spank

4,652GoAudience · generalComplexity · 1/5LicenseSetup · moderate

TLDR

A fun macOS program for Apple Silicon MacBooks that plays sound effects when you physically slap the laptop, using the built-in motion sensor to detect impacts.

Mindmap

mindmap
  root((spank))
    What it does
      Detect laptop slaps
      Play sound effects
      Fun project
    Sound modes
      Default random clips
      Escalating frequency mode
      Halo death sounds
      Custom MP3 folder
    Configuration
      Impact threshold
      Cooldown timer
      Playback pitch
    Tech
      Go
      Apple Silicon only
      IOKit HID
Click or tap to explore — scroll the page freely

Code map

Detail Auto

An interactive map of this repo's files and how they connect — its source is parsed live in your browser. Click Visualize to build it.

filefunction / class

Things people build with this

USE CASE 1

Set up your MacBook to play funny sound clips whenever it detects a hard knock or slap using its built-in accelerometer

USE CASE 2

Use custom MP3 files by pointing the program at your own audio folder instead of the built-in clips

USE CASE 3

Install as a background launch service so it starts automatically on login without opening a terminal

USE CASE 4

Tune the impact threshold and cooldown to avoid triggering on minor bumps during everyday use

Tech stack

Go

Getting it running

Difficulty · moderate Time to first run · 5min

Requires an M2 or M1 Pro MacBook and administrator privileges to read the hardware accelerometer via IOKit.

Use, modify, and distribute freely for any purpose, as long as you keep the copyright notice.

In plain English

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.

Copy-paste prompts

Prompt 1
I want to try Spank on my M2 MacBook. Walk me through installing and running it, including how to grant the administrator privileges it needs.
Prompt 2
How do I point Spank at my own folder of MP3 files to use custom sounds instead of the built-in clips?
Prompt 3
I want Spank to start automatically when I log in to macOS. Show me the exact commands to register it as a background service.
Prompt 4
How do I adjust Spank's acceleration threshold so it only triggers on hard hits and not small bumps while I type?
Open on GitHub → Explain another repo

← taigrr on gitmyhub — every repo by this author, as a profile.

Verify against the repo before relying on details.