Skip to content

krank56/bucklezig

Repository files navigation

🎹 BuckleZig

Mechanical Keyboard Sound Simulator for macOS

BuckleZig adds authentic mechanical keyboard sounds to any keyboard, giving your typing that satisfying click-clack feedback. Built with Zig for ultra-low latency audio (<10ms) and Go for a beautiful terminal UI.

Version Platform License

✨ Features

  • 🎵 System-wide keyboard capture - Works in every application
  • Ultra-low latency - <10ms from keypress to sound (~7-9ms achieved)
  • 🎨 Multiple Sound Profiles - Support for unlimited custom profiles
  • 🎚️ Real-time Volume Control - Adjust on-the-fly with visual feedback
  • 🚀 Instant Profile Switching - Hot-swap sounds without interruption
  • 💾 Persistent Config - Your preferences are automatically saved
  • 📦 Vim-style Navigation - Efficient keyboard-driven UI
  • 🖥️ Beautiful TUI - Powered by BubbleTea

📸 Screenshot

🎹 BuckleZig - Mechanical Keyboard Sounds

┌───────────────────────────────────┐
│ Active Profile: Cream             │
│ Volume: ████████░░ 80%            │
│ Sounds Played: 1,234              │
└───────────────────────────────────┘

┌───────────────────────────────────┐
│ Profiles:                         │
│                                   │
│   Cardboard                       │
│ ▸ Cream           [ACTIVE]        │
│   Crystal Purple                  │
│   Japanese Black                  │
│   Milky Yellow                    │
│   Oreo                            │
└───────────────────────────────────┘

● Ready - Keyboard capture active!

j/k: Navigate  •  Enter: Select Profile  •  +/-: Volume  •  q: Quit

🚀 Quick Start

Prerequisites

  • macOS 10.15+ (Catalina or later)
  • Zig 0.11+ (for building from source)
  • Go 1.21+ (for building from source)

Installation

# Clone the repository
git clone https://github.com/yourusername/bucklezig.git
cd bucklezig

# Build the application
make build

# Run BuckleZig
./bucklezig

⚠️ Sound Profiles Setup (Required)

Audio profiles are not included in this repository due to licensing compatibility with GNU GPL. You must add them manually:

  1. Create the profiles directory structure:

    mkdir -p profiles/{Cream,Cardboard,"Crystal Purple","Japanese Black","Milky Yellow",Oreo}
  2. Add your sound files:

    • Each profile directory needs 256 WAV files (16-bit, 44.1kHz recommended)
    • Files must be named: 1-down.wav, 1-up.wav, 2-down.wav, 2-up.wav, ..., 128-down.wav, 128-up.wav
    • X-down.wav = key press sound for keycode X
    • X-up.wav = key release sound for keycode X
  3. Example structure:

    profiles/
    ├── Cream/
    │   ├── 1-down.wav
    │   ├── 1-up.wav
    │   ├── 2-down.wav
    │   └── ... (256 files total)
    ├── Cardboard/
    └── ... (other profiles)
    
  4. Where to get sounds:

    • Record your own mechanical keyboard
    • Use royalty-free sound libraries
    • Create synthetic sounds with audio software
    • Ensure you have proper licensing rights for any sounds you use

Note: BuckleZig will not start without at least one complete profile directory.

First Launch

  1. Grant Accessibility Permissions (required for keyboard capture)

    • Go to System Preferences → Security & Privacy → Privacy → Accessibility
    • Click the lock icon and authenticate
    • Add your terminal app (Terminal.app, iTerm2, etc.) to the list
  2. Start Typing!

    • Type anywhere on your system to hear keyboard sounds
    • The default "Cream" profile loads automatically

🎮 Usage

Keybindings

Key Action
j / Navigate down in profile list
k / Navigate up in profile list
Enter / Space Activate selected profile
+ / ] Increase volume (10% increments)
- / [ Decrease volume (10% increments)
q / Ctrl+C Quit application

Switching Profiles

  1. Press j or k to navigate through the profile list
  2. Press Enter to activate the selected profile
  3. Your selection is automatically saved

Adjusting Volume

  1. Press + to increase volume
  2. Press - to decrease volume
  3. Watch the visual volume bar update
  4. Volume is automatically saved

📁 Project Structure

bucklezig/
├── zig/                    # Zig audio engine (performance-critical)
│   ├── src/audio/          # Audio playback, WAV loader, mixer
│   ├── src/keyboard/       # System-wide keyboard capture
│   └── src/profile/        # Profile loading and management
├── go/                     # Go TUI (user interface)
│   ├── cmd/bucklezig/      # Main entry point
│   └── internal/
│       ├── tui/            # BubbleTea interface
│       ├── bridge/         # CGO bridge to Zig
│       └── config/         # Configuration persistence
└── profiles/               # Sound profile WAV files
    ├── Cream/
    ├── Cardboard/
    ├── Crystal Purple/
    ├── Japanese Black/
    ├── Milky Yellow/
    └── Oreo/

🛠️ Development

Build Commands

# Clean build artifacts
make clean

# Build everything (Zig library + Go app)
make build

# Run tests
cd zig && zig build test      # Zig unit tests
cd go && go test ./...        # Go unit tests

# Format code
zig fmt zig/src/**/*.zig      # Zig formatting
cd go && gofmt -w .           # Go formatting

Architecture

BuckleZig uses a hybrid architecture:

  • Zig handles performance-critical audio and keyboard capture
  • Go provides the TUI and application logic
  • CGO bridges the two with minimal overhead

See ARCHITECTURE.md for detailed technical documentation.

🎯 Performance

BuckleZig meets all its performance targets:

Metric Target Achieved Status
Audio Latency <10ms ~7-9ms
Profile Switch <200ms Instant
Startup Time <500ms ~150ms
Memory Usage <100MB ~50-80MB
CPU Idle <1% <1%

🐛 Troubleshooting

No Sound When Typing

  • Verify system audio is working
  • Check volume isn't at 0% (press + to increase)
  • Ensure profiles directory exists with sound files: ls -la profiles/
  • Verify at least one complete profile with 256 WAV files is present

"Failed to start keyboard capture"

This means accessibility permissions aren't granted:

  1. System Preferences → Security & Privacy → Privacy → Accessibility
  2. Add your terminal app to the list
  3. Restart BuckleZig

Application Crashes

  • Rebuild with: make clean && make build
  • Check for error messages in terminal
  • Verify macOS version is 10.15+

See MANUAL_TEST.md for detailed troubleshooting.

📚 Documentation

🤝 Contributing

Contributions are welcome! Please:

  1. Follow the code style guidelines in AGENTS.md
  2. Add tests for new features (80% coverage minimum)
  3. Ensure all performance targets are met
  4. Update documentation as needed

📝 License

MIT License - See LICENSE file for details

🙏 Acknowledgments

  • Sound profiles inspired by popular mechanical keyboard switches
  • Built with BubbleTea TUI framework
  • Audio engine powered by Zig's excellent cross-platform capabilities
  • Developed with assistance from OpenCode and Claude Sonnet 4.5

👤 Author

Created by @krank56

🗺️ Roadmap

  • Linux support (evdev keyboard capture)
  • Windows support
  • Custom profile creator
  • Per-key sound customization
  • Audio effects (reverb, EQ, compression)
  • Profile import/export
  • Community profile sharing

Made with ❤️ and Zig