Slap your MacBook to trigger custom scripts and automations instantly
GitHub RepoImpressions3.6k

Slap your MacBook to trigger custom scripts and automations instantly

@githubprojectsPost Author

Project Description

View on GitHub

Spank Your MacBook to Run Scripts

We've all been there. You're deep in a flow state, and switching contexts to trigger a script or run a build feels like a jarring interruption. What if you could trigger those automations with something as simple and satisfying as a physical tap? Enter spank, a macOS utility that turns your laptop into a giant, programmable button.

It sounds like a joke, but the implementation is clever and surprisingly practical. This project bridges the digital and physical worlds in the most direct way possible, using the built-in accelerometer in modern MacBooks to detect a distinct "spank" and execute whatever you've wired it up to.

What It Does

spank is a lightweight, command-line tool for macOS that listens for a specific spike in accelerometer data—the kind generated by a firm tap on your laptop's case. When it detects that signature "spank," it executes a user-defined shell command or script. It runs quietly in the background, turning a physical action into a digital trigger.

Why It's Cool

The magic here is in the simplicity and the novel input method. You're not limited to keyboard shortcuts or mouse clicks. The use case is wide open:

  • Quick Actions: Spank to run your test suite, commit your code with a funny message, or toggle "Do Not Disturb."
  • Workflow Control: Spank to deploy a build, clear your cache, or restart a local server.
  • Silly Automations: Spank to send a "I'm running late" message, log your coffee break, or play a victory sound effect.

It's a fun, tactile reminder that our computers are physical objects. The project is also a great example of using macOS's underlying I/O Kit framework (AppleSMCMotionSensor) to access hardware sensors for creative purposes. It's a single, focused tool that does one weird thing very well.

How to Try It

Getting started is straightforward. You'll need a MacBook with an accelerometer (most modern ones have it).

  1. Install: The easiest way is via Homebrew:

    brew install taigrr/tap/spank
    

    You can also clone the GitHub repository and build from source.

  2. Run a Test: Try a simple command to see it in action. This will make your Mac speak when spanked:

    spank --command "say 'Ouch!'"
    
  3. Get Creative: Replace the --command argument with the path to any shell script or command you want. Run it in the background or set it up as a launch agent to have it always available.

Final Thoughts

Is spank a bit silly? Absolutely. But it's also a genuinely interesting hack that demonstrates how we can interact with our machines in new ways. For developers, it's a playground for creating instant, satisfying physical shortcuts for mundane digital tasks. It might not revolutionize your workflow, but it will definitely put a smile on your face the first time you literally slap your laptop to run a deploy script. Give it a try and see what you automate.


@githubprojects

Back to Projects
Project ID: a5c06b5f-c758-48f3-8a8d-35bb0eb24680Last updated: March 1, 2026 at 09:11 AM