Global key listening
Uses Python's pynput listener to react to key presses outside the terminal when the operating system permits it.
A small Bash-powered utility that plays your chosen MP3 whenever you press a key. Set it up once, control it from your terminal, and let the clicks begin.
Keyboard-MP3 keeps the workflow straightforward: configure a file, start the background listener, and manage it with a few memorable commands.
Uses Python's pynput listener to react to key presses outside the terminal when the operating system permits it.
Choose an existing MP3 file and use it as the sound played when a key is pressed. Playback is handled by pygame.
Start the listener from your shell and keep using other applications. Stop it when you want quiet again.
Point the utility to another sound file from the terminal. If the listener is running, the CLI attempts to restart it.
No large control panel to navigate. Use on, off, status, and change.
The utility stores its sound path, helper, virtual environment, PID file, and log under your home directory.
The command-line interface is Bash-based and the listener is Python-based. Global keyboard monitoring depends on your desktop session and operating-system permissions.
macOS may ask you to grant your terminal application permission to observe keyboard input.
Support varies by desktop environment, display server, and input-device permissions.
echo "$XDG_SESSION_TYPE".pynput may not detect keys in other apps.Download the installer from the repository, run it from a terminal, then set the sound file you want to use.
Requires Python 3 and a working Python virtual-environment setup.
bash ~/Downloads/install-keyboard-mp3.shReplace the example with the full path to an existing MP3 file.
export PATH="$HOME/bin:$PATH"
keyboard-mp3 change "$HOME/Music/keyboard.mp3"Start the listener and type in another application to test it.
keyboard-mp3 onTurn the sound off or check whether the listener is running.
keyboard-mp3 status
keyboard-mp3 offLinux note: on Debian/Ubuntu, you may need system packages for Python venv/build dependencies or audio libraries if pip cannot install a dependency. Package requirements vary by system.
Select a command to see what it does and copy an example.
Launches the keyboard listener in the background using the currently configured sound file. If a listener is already running, the CLI reports that state.
keyboard-mp3 onKeyboard-MP3 keeps its helper, environment, configuration, and runtime log in predictable locations under your home directory.
~/bin/keyboard-mp3 — Bash command-line interface~/.local/share/keyboard-mp3/listener.py — Python listener and audio helper~/.local/share/keyboard-mp3/venv/ — Python virtual environment and dependencies~/.local/share/keyboard-mp3/sound-path — Configured sound-file path~/.local/share/keyboard-mp3/listener.pid — Background process ID file~/.local/share/keyboard-mp3/listener.log — Listener output and error logcat ~/.local/share/keyboard-mp3/listener.logStart with these common fixes before digging into the log.
Ensure ~/bin is on your PATH: run export PATH="$HOME/bin:$PATH". Open a new terminal or source the relevant shell startup file afterward.
On macOS, review Accessibility and Input Monitoring permissions. On Linux, check whether your session uses X11 or Wayland; Wayland may prevent global monitoring.
Confirm the configured file exists, check system output volume, and inspect ~/.local/share/keyboard-mp3/listener.log for audio or MP3-loading errors.
Yes. Quote the path, for example: keyboard-mp3 change "$HOME/Music/My Keyboard Sound.mp3".
No. This is a documentation and demo site. It cannot install or control the native Python listener on your computer.
Run keyboard-mp3 off, then remove ~/bin/keyboard-mp3 and ~/.local/share/keyboard-mp3. Remove the PATH line from your shell startup file if you no longer need it.
Explore the source, read the README, or contribute improvements on GitHub.