Overview
Running Spank as a service:- Starts automatically at boot
- Restarts automatically if it crashes (
KeepAlive) - Runs with root privileges (required for accelerometer access)
- Logs output to
/tmp/spank.logand/tmp/spank.err
Creating the launchd Plist
A launchd plist is an XML configuration file that tells macOS how to run your service. Choose the configuration that matches your desired mode:- Pain Mode (Default)
- Sexy Mode
- Halo Mode
- Custom Mode
Update the binary path: If you installed Spank elsewhere (e.g.,
~/go/bin/spank), update the <string>/usr/local/bin/spank</string> line to match your installation path.Understanding the Plist Keys
| Key | Value | Purpose |
|---|---|---|
Label | com.taigrr.spank | Unique identifier for the service |
ProgramArguments | Array of strings | Command and flags to execute |
RunAtLoad | true | Start the service immediately when loaded |
KeepAlive | true | Automatically restart if the process exits |
StandardOutPath | /tmp/spank.log | Where to write stdout logs |
StandardErrorPath | /tmp/spank.err | Where to write stderr logs |
UserName key?
Since the plist is in /Library/LaunchDaemons (system-wide) and has no UserName key, launchd runs it as root automatically. This is necessary because Spank requires root privileges for IOKit HID accelerometer access.
Source: README.md:176
Loading and Starting the Service
Once you’ve created the plist file, load it with launchd:- Start immediately (due to
RunAtLoad) - Start automatically on every boot
- Restart automatically if it crashes
README.md:172-174
Stopping and Unloading the Service
To temporarily stop the service without removing it:README.md:180-182
Use
stop for temporary shutdowns. Use unload when you want to disable the service permanently or before deleting/editing the plist file.Viewing Logs
Spank outputs logs to two files:Adding Sensitivity Settings
You can add the--min-amplitude flag to your plist configuration:
Troubleshooting
Service won't start
Service won't start
Check the error log:Common issues:
- Incorrect binary path in plist
- Spank binary not executable:
chmod +x /usr/local/bin/spank - Invalid plist XML syntax
Service starts but doesn't detect slaps
Service starts but doesn't detect slaps
Check if the process is running:Check the logs:You should see:
spank: listening for slaps in [mode] mode...If not, check /tmp/spank.err for errors.Changes to plist not taking effect
Changes to plist not taking effect
After editing the plist file, you must unload and reload it:
Service keeps restarting
Service keeps restarting
If Spank is crashing repeatedly, check the error log:Common causes:
- Accelerometer access denied (requires sudo/root)
- Custom audio directory doesn’t exist
- Invalid command-line flags
Removing the Service
To completely remove Spank as a service:Security Considerations
What Spank accesses:- IOKit HID interface for accelerometer data
- Audio output device
- File system (only to read embedded/custom MP3s)
- Network (no internet connection required)
- Your files (beyond the custom MP3 directory if specified)
- Keyboard or mouse input
main.go:1-393 (entire implementation is transparent and open source)