https://github.com/rivethorn/hyprsonic
A small app to make keyboard sounds on Hyprland
https://github.com/rivethorn/hyprsonic
hyprland keyboard linux linux-app mechanical-keyboard python script udev wayland
Last synced: 4 months ago
JSON representation
A small app to make keyboard sounds on Hyprland
- Host: GitHub
- URL: https://github.com/rivethorn/hyprsonic
- Owner: rivethorn
- Created: 2025-09-15T23:29:27.000Z (5 months ago)
- Default Branch: main
- Last Pushed: 2025-09-15T23:51:36.000Z (5 months ago)
- Last Synced: 2025-09-16T01:19:11.538Z (5 months ago)
- Topics: hyprland, keyboard, linux, linux-app, mechanical-keyboard, python, script, udev, wayland
- Language: Python
- Homepage:
- Size: 4.88 KB
- Stars: 0
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README
Awesome Lists containing this project
README
Hyprsonic
---------
Hyprsonic is a bespoke low-latency keyboard sound player for Linux, specifically Hyprland. It listens to a keyboard device using evdev and plays short keypress/keyup sounds via miniaudio. Sounds are mixed in-process so multiple key events can overlap with minimal latency.
## Requirements
- Linux (evdev input system)
- Python 3.8+
- See `requirements.txt` for dependencies; main packages:
- `evdev` (for keyboard events)
- `miniaudio` (for decoding and playback)
## Installation
1. Clone or copy the repository to a local folder.
2. Enter the venv.
python -m venv venv
source venv/bin/activate.fish
3. Install dependencies.
pip install -r requirements.txt
4. Place your WAV sound files in the directory `~/.local/share/hyprsonic/` (create it if missing). The program expects the following files (fallbacks are listed in-code):
- `fallback.wav` (regular key down)
- `fallback-up.wav` (regular key up)
- `fallback2.wav` / `fallback2-up.wav` (alternate sounds)
- `enter.wav` / `enter-up.wav`
- `backspace.wav` / `backspace-up.wav`
- `spacebar.wav` / `spacebar-up.wav`
Note: WAV files should preferably be 16-bit PCM. The script will decode and resample to 48 kHz stereo signed 16-bit during load.
## Usage
Run the main script as root or with appropriate permissions to read input devices (you may need to run with sudo or add yourself to the `input` group):
python hyprsonic.py
Or chmod +x and simply run:
./hyprsonic.py
On startup the script prints the chosen keyboard device path and starts audio playback. Press Ctrl+C to stop.
## Configuration
- You can change the base path where the script looks for audio files by editing the `BASE` variable near the top of `hyprsonic.py`.
- Output sample rate, channels and format can be adjusted via the `OUT_SAMPLE_RATE`, `OUT_CHANNELS` and `OUT_FORMAT` constants.