taigrr/spank: a Go CLI that reads the Apple Silicon accelerometer and plays audio when you hit the lid
Slap your MacBook, it yells back. Uses Apple Silicon accelerometer via IOKit HID.
At a glance
- What is it?
- spank is a single-binary Go tool for Apple Silicon Macs that reads the Bosch BMI286 IMU through IOKit HID, runs vibration detection, and plays an embedded MP3 when you slap the laptop. It is a toy with real hardware constraints, and the constraints are the interesting part.
- Who is it for?
- Adopt spank if you have an M2-or-newer Apple Silicon Mac, you are comfortable running a root process that reads a sensor through IOKit HID, and you want a small, readable Go program that demonstrates the detection pipeline. Do not adopt it on Intel Macs, on M1 or A-series chips, on anything but macOS, or in any environment where a root launchd daemon reading an accelerometer is a problem.
- Can I use it commercially?
- Yes. MIT is a permissive licence: you can use, modify and sell software built on it, as long as you keep its copyright and licence notices.
- Is it still maintained?
- Yes. The repository last received commits 39 days ago.
- What is it written in?
- Mainly Go, according to GitHub's language statistics.
Answers come from the project's GitHub data, last synced on September 30, 2026, and from our analysis. They are not legal advice.
Editorial analysis
The problem spank solves, and the machines it refuses to solve it on
Apple Silicon laptops contain an accelerometer that macOS does not expose through a documented public API. spank's premise is that this sensor is reachable anyway, through IOKit HID, and that once you can read it you can do something with the readings. What it does with them is deliberately unserious: detect a physical impact on the chassis and play a sound. The README's own summary is "Slap your MacBook, it yells back."
The audience is correspondingly narrow. This is for people who want a working example of reading the Apple SPU sensor from Go, or who want the joke, or both. It is not a library, not a framework, and not something you would put in a product. The hard boundary is hardware. According to the README's Requirements section, you need macOS on Apple Silicon with "any M-series chip M2 or greater, or the M1 Pro SKU specifically, no other M1/A-series chips." That is an unusually specific exclusion list, and it is the first thing to check before you spend time on anything else. If your machine is an M1 (non-Pro), an Intel Mac, or an iPhone, spank is not for you, and no amount of configuration changes that.
The second boundary is privilege. Reading the sensor goes through IOKit HID, and the README states that `sudo` is required for that access. Every invocation in the usage section is written as `sudo spank`. A tool that needs root to listen to a sensor is a tool you should think about before you make it start at boot.
How the detection pipeline actually works
The README's "How it works" list is short and specific. spank reads raw accelerometer data directly via IOKit HID from the Apple SPU sensor. It then runs vibration detection, described as STA/LTA, CUSUM, kurtosis, and peak/MAD. When a significant impact is detected, it plays an embedded MP3 response. A 750ms cooldown between responses prevents rapid-fire, adjustable with `--cooldown`.
That is a classic seismic-detection stack. STA/LTA compares a short-term average of signal energy to a long-term average, which is how you separate a transient from background noise. CUSUM accumulates small deviations to catch a change point. Kurtosis measures how peaked a distribution is, which distinguishes a sharp impulse from ordinary motion. Peak/MAD compares the peak against the median absolute deviation, a threshold that adapts to the noise floor rather than sitting at a fixed value. Porting that combination to a laptop accelerometer is a reasonable choice, because the sensor sees a lot of benign motion (typing, picking the machine up, setting it down) and a slap is a short, high-amplitude event. The README credits the sensor reading and vibration detection as ported from olvvier/apple-silicon-accelerometer, and go.mod shows the dependency `github.com/taigrr/apple-silicon-accelerometer v0.1.0`, so the detection logic is not entirely inside this repository.
The rest of the pipeline is straightforward. Audio playback uses `github.com/gopxl/beep/v2`, decoding MP3 through `github.com/hajimehoshi/go-mp3` and outputting through `github.com/ebitengine/oto/v3`, all visible in go.mod. The CLI layer is Cobra plus Charm's fang, which is why the usage examples have the polished help output. Two optional behaviours sit on top of detection: `--volume-scaling` makes light taps play quietly and hard slaps play at full volume, and `--speed` adjusts playback speed and pitch, with 0.5 as half speed and 2.0 as double speed. The `--speed` flag is also documented as taking a default of 1.0.
Installing spank and getting a first slap to register
The README offers two install paths. You can download a binary from the latest release, or build from source with `go install`. Building requires Go 1.26 or newer, which matches the `go 1.26.4` directive in go.mod. If you build from source, the README warns that `go install` puts the binary in `$GOBIN` or `$(go env GOPATH)/bin`, and that you should copy it to a system path so that `sudo spank` works. The README's own example uses the default Go settings:
go install github.com/taigrr/spank@latest
sudo cp "$(go env GOPATH)/bin/spank" /usr/local/bin/spankAfter that, run it in the default pain mode. The README says this randomly plays from 10 pain or protest audio clips when a slap is detected. Expect a prompt for your password, and expect nothing to happen until you actually strike the chassis.
sudo spankIf nothing triggers, the first knob is sensitivity. The README documents `--min-amplitude` with a default of 0.05, described as the minimum acceleration amplitude in g-force required to trigger a sound. Lower values detect light taps. The README's own example for a more sensitive run uses 0.1:
sudo spank --min-amplitude 0.1If it triggers too often, raise the value. The README groups 0.15 to 0.30 as balanced and 0.30 to 0.50 as strong impacts only. There is also a `--fast` profile that changes several values at once: faster polling (4ms versus 10ms), shorter cooldown (350ms versus 750ms), higher sensitivity (0.18 versus 0.05 threshold), and a larger sample batch (320 versus 200). Note that the fast profile's threshold of 0.18 is higher than the default 0.05, so "higher sensitivity" there refers to the polling and cooldown behaviour rather than to the amplitude gate. The README states you can still override individual values with `--min-amplitude` and `--cooldown` when needed.
For custom audio, `--custom` takes a directory of MP3 files. The other modes are `--sexy`, which tracks slaps in a rolling 5-minute window across 60 levels of escalation, and `--halo`, which plays death sounds from the Halo series.
Running spank as a root launchd daemon, and what that costs you
The README documents a launchd plist for boot-time startup, with separate snippets for pain, sexy, and halo modes. The label is `com.taigrr.spank`, and the plist goes in `/Library/LaunchDaemons/`. Because the plist lives there and no `UserName` key is set, launchd runs it as root, so no `sudo` is needed at invocation. The README's pain-mode snippet points `ProgramArguments` at `/usr/local/bin/spank`, sets `RunAtLoad` and `KeepAlive` to true, and writes logs to `/tmp/spank.log` and `/tmp/spank.err`. You load it with:
sudo launchctl load /Library/LaunchDaemons/com.taigrr.spank.plistAnd unload it with:
sudo launchctl unload /Library/LaunchDaemons/com.taigrr.spank.plistHere is the trade-off the README does not editorialize about. A persistent root daemon that reads a motion sensor and plays audio on a laptop is a strange thing to have running permanently. `KeepAlive` means launchd restarts it if it exits, so a crash loop becomes a restart loop. The README notes that you should update the path if you installed spank elsewhere, for example `~/go/bin/spank`, but a daemon pointing at a home directory path under a root context is a configuration you should avoid. If you only want the effect while you are at the machine, running `sudo spank` in a terminal is the lower-commitment option, and unloading the plist is one command when you are done.
There is also an interaction with `--sexy` worth noting: it tracks slaps within a rolling 5-minute window and escalates through 60 levels. Under a `KeepAlive` daemon, that state lives as long as the process, so the escalation counter persists across your whole session rather than resetting when you close a terminal.
Where spank is the wrong tool
The most obvious failure mode is a false positive. The detection stack is tuned for impulsive events, but a laptop accelerometer also sees the machine being moved, a desk being bumped, a heavy object set down nearby, and possibly typing on a stiff keyboard. The `--min-amplitude` flag is the only documented lever for this, and it is a single global threshold. There is no documented per-axis filter, no documented way to exclude a specific direction of motion, and no documented calibration step. If your environment is noisy, you will be raising the threshold until only hard slaps register, at which point you have lost the light-tap behaviour that made the tool fun.
The second limitation is the cooldown. The default is 750ms and `--fast` drops it to 350ms. That is a floor on how fast responses can follow each other. If you want a sound per impact in a rapid sequence, the cooldown is working against you, and lowering it trades responsiveness for the risk of overlapping playback.
The third is platform and privilege, already covered but worth stating as a limitation rather than a requirement. spank cannot run without root, cannot run on non-Apple-Silicon hardware, and cannot run on M1 or A-series chips. The README does not document a way to run it without elevated privileges, and it does not document a fallback sensor path.
Finally, the README does not document rollback or uninstall beyond the `launchctl unload` command. If you install the daemon, remove the plist yourself and unload it; there is no `spank uninstall` in the documented flags.
Alternatives and how their approach differs
The README names its upstream: sensor reading and vibration detection were ported from olvvier/apple-silicon-accelerometer, and go.mod pins `github.com/taigrr/apple-silicon-accelerometer v0.1.0`. That project is the real alternative if what you want is the accelerometer data rather than the joke. The difference in approach is the layer each one stops at. apple-silicon-accelerometer is about getting the readings out; spank wraps that in a detection pipeline, an audio playback stack, a CLI with modes and tuning flags, and a launchd service recipe. If you want to plot the sensor, log it, or feed it into your own logic, the upstream is the smaller dependency. If you want the specific behaviour of a sound on impact, with the mode presets and the sensitivity and cooldown flags already wired, spank is the packaged version of that.
The second alternative is not to use the accelerometer at all. A microphone-based impact detector would work on any Mac, including Intel and M1 machines, and would not need IOKit HID or root for sensor access. It would also pick up every other loud noise in the room, which is exactly the problem the accelerometer avoids: the sensor measures the chassis, not the air. That is the design bet spank makes, and it is why the hardware requirement is so tight. You are trading portability for a signal that is physically tied to the object you are hitting.
Maintenance, licence, and what you are taking on
The repository is not archived, and the last push was on 2026-08-23. Recent releases are v1.3.0 on 2026-07-03, v1.2.5 on 2026-03-27, and v1.2.4 on 2026-03-08, so the release cadence over the past several months has been modest rather than rapid. There is a `.goreleaser.yaml` at the top level, which is how the release binaries are produced, and both `flake.nix` and `flake.lock` plus a `nix/` directory, so there is a Nix build path alongside the Go one. The presence of `main_test.go` and `stdin_test.go` indicates the CLI is tested at the top level, though the README does not describe a test suite or CI configuration. There is also an `AGENTS.md` at the root, which suggests the project anticipates automated contributions.
The upgrade cost is low in the ordinary case: it is a single Go binary, and `go install github.com/taigrr/spank@latest` plus copying it to `/usr/local/bin/spank` is the whole update. If you run it as a launchd daemon, remember that `KeepAlive` will restart the old binary until you unload and reload the plist, so an update means unloading, replacing the binary, and loading again.
The licence is MIT, stated in both the README and the LICENSE file. MIT is permissive: it allows use, modification, and redistribution with the licence and copyright notice retained. The audio assets are the part to look at yourself. The repository has an `audio/` directory, and the halo mode plays "death sound effects from the Halo video game series," which is a third-party franchise. The README does not state the provenance or licence of those clips, and MIT on the code does not automatically cover bundled audio. If you redistribute the binary or its assets, that is the question to resolve first. This is not legal advice; read the licence and check the audio directory.
Editorial conclusion
Adopt spank if you have an M2-or-newer Apple Silicon Mac, you are comfortable running a root process that reads a sensor through IOKit HID, and you want a small, readable Go program that demonstrates the detection pipeline. Do not adopt it on Intel Macs, on M1 or A-series chips, on anything but macOS, or in any environment where a root launchd daemon reading an accelerometer is a problem. Before installing, verify three things: that your chip matches the requirement, that `--min-amplitude 0.1` triggers on your surface and your slaps rather than on typing or on the desk, and that you have copied the binary out of `$(go env GOPATH)/bin` into a system path, because `sudo spank` will not find it otherwise.
Frequently asked questions
How do I install spank?
Download a binary from the latest release, or build from source with `go install github.com/taigrr/spank@latest`, which requires Go 1.26 or newer. Because `go install` places the binary in `$GOBIN` or `$(go env GOPATH)/bin`, the README recommends copying it to a system path such as `/usr/local/bin/spank` so that `sudo spank` works.
What is spank?
spank is a Go command-line tool for Apple Silicon Macs that reads the accelerometer through IOKit HID, detects physical impacts on the laptop, and plays audio in response. The README describes it as "Slap your MacBook, it yells back" and lists pain, sexy, halo, and custom audio modes.
What Macs can run spank?
The README requires macOS on Apple Silicon with any M-series chip M2 or greater, or the M1 Pro specifically, and states that no other M1 or A-series chips are supported. It also requires sudo for IOKit HID accelerometer access.
Why does spank need sudo?
The README lists sudo as a requirement because spank reads the accelerometer through IOKit HID, and that access is privileged. Every usage example in the README is written as `sudo spank`.
How do I make spank more or less sensitive?
Use `--min-amplitude`, which the README documents as the minimum acceleration amplitude in g-force required to trigger a sound, with a default of 0.05. Lower values such as 0.05 to 0.10 detect light taps, while 0.30 to 0.50 triggers only on strong impacts.
Can spank play my own audio files?
Yes. The README documents `--custom /path/to/mp3s`, which randomly plays MP3 files from a directory you specify.
Official sources
Add this badge to your README
If you maintain this project, the badge below links readers to this analysis and shows its maintenance status from the daily GitHub snapshot. Paste the markdown into your README; add ?metric=license or ?metric=stars to the image URL for a different field.
[](https://hysenlabs.com/projects/taigrr-spank)