Quickstart
This guide gets you from installation to your first successful slap detection.Run Spank with default settings
Start Spank in pain mode (the default):You should see:
Spank requires sudo for IOKit HID access to the accelerometer. This is a hardware requirement.
Slap your laptop
Gently slap the palm rest or keyboard area of your MacBook. You should hear an audio response (“ow!”) and see console output:The output shows:
- Slap number (sequential counter)
- Severity classification (light/medium/hard)
- Amplitude in g-force
- Audio file played
Adjust sensitivity (optional)
If detection is too sensitive or not sensitive enough, use the The value represents minimum acceleration amplitude in g-force (0.0-1.0). From main.go:200:Recommended ranges:
--min-amplitude flag:- Very sensitive (light taps): 0.05-0.10
- Balanced: 0.15-0.30 (default: 0.3)
- Only strong impacts: 0.30-0.50
Try different modes
Spank has multiple audio modes. Stop the current session (Ctrl+C) and try:Pain mode: Randomly plays from 10 pain/protest audio clips.Sexy mode: Tracks slaps within a rolling window. The more you slap, the more intense the audio. Uses exponential decay with a 30-second half-life (main.go:66) to create 60 levels of escalation.Halo mode: Randomly plays death sounds from Halo video games.Custom mode: Randomly plays your own MP3 files from a specified directory.
Modes are mutually exclusive. You can only use one at a time.
Understanding the output
When a slap is detected, you’ll see output like:slap #3: Third slap since Spank started (from main.go:343)[hard amp=0.67234g]: Severity and amplitude in g-forceaudio/pain/ow-07.mp3: Audio file played
How detection works
Spank processes accelerometer data continuously:-
Sensor polling: Reads accelerometer at 100Hz (every 10ms) from main.go:72:
-
Batch processing: Processes up to 200 samples per tick (main.go:76):
- Event detection: Uses vibration detection algorithms (STA/LTA, CUSUM, kurtosis, peak/MAD) to identify impacts
-
Threshold filtering: Only triggers if amplitude >=
min-amplitude(main.go:336-338): -
Cooldown: 750ms minimum between audio playback (main.go:69):
Common workflows
Run Spank continuously
To keep Spank running in the background:Combine sensitivity with modes
You can adjust sensitivity for any mode:Stop Spank
PressCtrl+C in the terminal, or if running in background:
Next steps
Run as a service
Set up Spank to start automatically at boot using launchd
Advanced configuration
Explore custom audio directories and fine-tune detection parameters
Troubleshooting
No slaps detected
No slaps detected
- Verify you’re running with
sudo - Lower the threshold:
sudo spank --min-amplitude 0.1 - Try slapping harder or on different parts of the laptop
- Check that your chip is M2+ (M1 not supported)
Too many false positives
Too many false positives
- Raise the threshold:
sudo spank --min-amplitude 0.4 - Ensure your laptop is on a stable surface
- The default cooldown (750ms) prevents most false triggers
No audio playback
No audio playback
- Check system audio volume
- Verify audio output device is not muted
- Test with a different mode (e.g.,
--halo) - Check console for error messages about audio decoding
Spank crashes immediately
Spank crashes immediately
- Ensure you have sudo:
sudo spank - Check that no other process is using the accelerometer
- Verify macOS version compatibility (requires recent macOS on Apple Silicon)