klack is a lightweight, zero-configuration mechanical keyboard sound simulator for Linux. It runs seamlessly in the background, listens directly to your selected input devices, and is designed to be easily managed as a standard systemd user service.
The application is completely agnostic to the host windowing system or compositor, so will work the same whether you are on Wayland, X11, or running in a bare TTY.
This project started as a quick afternoon project after trying out Opera GX, and liking the typing sounds feature it includes. My original intent was just to implement it for fun as a personal project, but I decided others may find use for it, so cleaned it up and turned it into a proper application.
https://codeberg.org/ForeverZer0/klack
Installation
Ensure you have Zig >= 0.16.0 installed. Clone the repository and build using the release configuration:
git clone ssh://[email protected]/ForeverZer0/klack.git
cd klack
zig build -Doptimize=ReleaseFast
You can optionally specify the maximum number of voices that can play simultaneously as a build option (default: 8). This value cannot be changed at runtime.
zig build -Doptimize=ReleaseSmall -Dmax_voices=16
The compiled binary will be available at zig-out/bin/klack.
Usage
klack - A mechanical keyboard sound simulator
USAGE:
klack [OPTIONS]
OPTIONS:
-s, --soundpack <PATH> Path to a directory or .tar.gz archive containing sounds
-d, --device <NAME> Target device name (default: primary keyboard)
-v, --volume <VOLUME> Volume scaling from 0.0 to 1.0 (default: 1.0)
-r, --repeat Enable sound playback on key repeat events
-b, --background Run the process in the background (daemonize)
--list-devices List available input devices and exit
--list-keys List valid key names for custom sounds
--list-buttons List valid button names for custom sounds
-h, --help Print this help message and exit
EXAMPLES:
klack --soundpack ~/.config/klack/mx-blues.tar.gz --background
klack -s ./sounds/custom/ -v 0.7 --repeat
klack --list-devices
Quick Examples
Run manually in the foreground with a specific sound archive:
klack --soundpack ~/.config/klack/typewriter.tar.gz
Run in the background with a lower volume and key-repeat sounds enabled:
klack -s ./sounds/custom/ -v 0.7 --repeat --background
Environment Variables
The following environment variables may also be used to provide default configuration for options not specified on the command-line, which always have precedence.
KLACK_SOUNDPACKKLACK_DEVICEKLACK_VOLUMEKLACK_REPEAT
LLM/AI Usage
- No LLM or AI was used for any code within this project, and never will.
- Google Gemini was used to generate the logo. Full credit goes to all the unnamed artists who had their work used for its training data.
Supported Zig versions
Zig 0.16+
Tested on the following:
- 0.16.0
- 0.17.0-dev.1397+4331ba0fb
0 Comments
Log in to join the conversation.No comments yet. Be the first to share your thoughts.