A cross-platform background script that plays an audio file when you press a configurable global hotkey. Works on Windows, macOS, and Linux.
macOS / Linux
curl -fsSL https://raw.githubusercontent.com/manuvikash/Fah/main/install.sh | bashWindows (PowerShell)
irm https://raw.githubusercontent.com/manuvikash/Fah/main/install.ps1 | iex- Global hotkey (works in any application)
- User-configurable keybind via
config.yaml - Plays audio from start on each keypress (allows overlapping)
- Runs silently in the background
- Cross-platform (Windows & macOS)
- Python 3.7 or higher
- pip (Python package manager)
-
Clone or download this repository
-
Install Python dependencies:
pip install -r requirements.txtOr install individually:
pip install pynput pyyaml- Add custom audio file (optional):
- After installation the configuration directory is:
- Windows:
%APPDATA%\\fah - macOS/Linux:
~/.config/fah
- Windows:
- Place your
fah.mp3file in that config directory, or updateconfig.yamlto point to your audio file location
- Configure your keybind (see Configuration section below)
Edit config.yaml to customize your keybind:
keybind:
modifiers: ["ctrl", "shift"] # Modifier keys to hold
key: "f" # Main key to press
audio_file: "fah.mp3" # Path to your audio filectrl- Control key (works on both Windows and macOS)alt- Alt key (Option on macOS)shift- Shift keycmd- Command key (macOS only)win- Windows key (Windows only)
- Any letter:
athroughz - Any number:
0through9 - Function keys:
f1throughf12
Ctrl+Shift+F:
keybind:
modifiers: ["ctrl", "shift"]
key: "f"Ctrl+Alt+P:
keybind:
modifiers: ["ctrl", "alt"]
key: "p"F9 (no modifiers):
keybind:
modifiers: []
key: "f9"Cmd+Shift+Space (macOS):
keybind:
modifiers: ["cmd", "shift"]
key: "space"Windows:
python audio_hotkey.pymacOS/Linux:
python3 audio_hotkey.pyPress Ctrl+C to stop the script.
Windows:
start_windows.batThis launches fah using pythonw.exe (no console window). To stop the running process safely:
rem List pythonw processes and PIDs
tasklist /FI "IMAGENAME eq pythonw.exe"
rem Then terminate the specific PID
taskkill /PID <pid>If you intentionally want to force-stop all headless Python processes (may affect other apps):
taskkill /F /IM pythonw.exemacOS/Linux:
./start_mac.shstart_mac.sh launches fah with nohup and writes the process id to .fah.pid in the project directory. To stop the instance started by the script:
kill $(cat .fah.pid)
rm .fah.pidFallback options if you didn't use the PID file:
pkill -f fah
pkill -f audio_hotkey.pyUse Task Scheduler to run the script on startup:
- Open Task Scheduler (search in Start menu)
- Click Create Basic Task
- Name it "Audio Hotkey Player"
- Trigger: When I log on
- Action: Start a program
- Program/script: Browse to
start_windows.bat - Finish and test by restarting
Alternative: Using Startup Folder
- Press
Win+Rand type:shell:startup - Create a shortcut to
start_windows.batin that folder - The script will run on every login
Use launchd to run the script on startup:
- Create a plist file at
~/Library/LaunchAgents/com.audiohotkey.plist:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Label</key>
<string>com.audiohotkey.player</string>
<key>ProgramArguments</key>
<array>
<string>/usr/bin/python3</string>
<string>/FULL/PATH/TO/audio_hotkey.py</string>
</array>
<key>RunAtLoad</key>
<true/>
<key>KeepAlive</key>
<true/>
<key>StandardOutPath</key>
<string>/tmp/audiohotkey.log</string>
<key>StandardErrorPath</key>
<string>/tmp/audiohotkey.error.log</string>
</dict>
</plist>-
Replace
/FULL/PATH/TO/audio_hotkey.pywith the actual path (e.g.,/Users/username/fah/audio_hotkey.py) -
Load the agent:
launchctl load ~/Library/LaunchAgents/com.audiohotkey.plist- To unload/stop:
launchctl unload ~/Library/LaunchAgents/com.audiohotkey.plistAlternative: Using Login Items
- Open System Preferences > Users & Groups
- Click Login Items tab
- Click + and add
start_mac.sh - The script will run when you log in
On macOS, you'll need to grant Accessibility permissions:
- Run the script once
- macOS will prompt you to allow Terminal (or Python) to control your computer
- Go to System Preferences > Security & Privacy > Privacy > Accessibility
- Add Terminal or Python to the allowed apps list
On Windows, no special permissions are typically required. If you encounter issues:
- Run Terminal/PowerShell as Administrator when installing dependencies
- Some antivirus software may flag global keyboard hooks; add an exception if needed
- Ensure
fah.mp3is placed in the configuration directory after installation:- Windows:
%APPDATA%\\fah - macOS/Linux:
~/.config/fahOr specify the full path inconfig.yaml
- Windows:
- Check that your keybind doesn't conflict with other applications
- Try a different key combination
- On macOS, ensure Accessibility permissions are granted
- Verify Python 3 is installed:
python3 --version - Check all dependencies are installed:
pip list - Look for error messages in the console output
If you can't stop the background process, use the platform-specific steps below.
Windows (find PID then kill):
tasklist /FI "IMAGENAME eq pythonw.exe"
taskkill /PID <pid>Windows (force all headless Python processes - use with caution):
taskkill /F /IM pythonw.exemacOS/Linux (PID file created by start_mac.sh):
kill $(cat .fah.pid)
rm .fah.pidmacOS/Linux (fallback):
pkill -f fah
pkill -f audio_hotkey.py- The script loads your configuration from
config.yaml - It resolves an available system audio player command and uses a subprocess to play the audio (no external audio library required)
- It sets up a global keyboard listener using pynput
- When your configured keybind is pressed, it plays the audio file
- Each keypress plays from the start (overlapping audio is allowed)
Free to use and modify for personal projects.
If you encounter issues:
- Check the Troubleshooting section above
- Verify your Python version and dependencies
- Try running in foreground mode to see error messages
- Check platform-specific permissions