This Python script enables the special "Predator" key (usually located above the keyboard on Acer Predator laptops) to work under Linux.
| Model | Module | Kernel Input | Event Device |
|---|---|---|---|
| Acer Predator Helios 16 | PH16-71 | ABS_MISC |
/dev/input/event9 |
| Acer Predator Helios 300 | PH315-52 | KEY_PRESENTATION |
/dev/input/event4 |
Note: With auto-detection, the script works on any Acer Predator model without manual configuration!
- Auto-Detection: Automatically detects the correct input device and key code
- Smart Caching: Saves configuration for instant startup on subsequent runs
- Universal Compatibility: Works across different Acer Predator models without manual configuration
- Immediate Execution: Runs your command from the very first press
- Background Mode: Run as daemon without blocking startup scripts
- Maps the key press to any custom command or script
- Optional support for multiple additional commands
- Built-in debounce to prevent repeated triggers
- Works on startup
You can run the script automatically at login using one of the following methods:
Add to your config file (e.g., ~/.config/bspwm/bspwmrc or ~/.config/i3/config):
sudo python3 /full/path/to/Predator/Predator-Key.py --run-backgroundAdd to ~/.config/hypr/hyprland.conf:
exec-once = sudo python3 /full/path/to/Predator/Predator-Key.py --run-backgroundCreate a .desktop entry:
cat > ~/.config/autostart/predator-key.desktop << EOF
[Desktop Entry]
Name=Predator Key Handler
Exec=sudo python3 /full/path/to/Predator/Predator-Key.py --run-background
Type=Application
Hidden=false
NoDisplay=false
X-GNOME-Autostart-enabled=true
EOFNote: Always use
--run-backgroundflag for startup scripts to prevent blocking!
- Python 3
evdevlibrary (pip install evdev)- Access to input devices (
/dev/input/event*)
-
Clone the repo:
git clone https://github.com/Order52/predator-key cd predator-key -
Install dependencies:
pip install evdev
-
(Optional) Add your user to the
inputgroup:sudo usermod -aG input $USER newgrp input -
Make the script executable:
chmod +x Predator/Predator-Key.py
Edit the PREDATOR_KEY_COMMAND in the script to your desired command:
cd ~/predator-key/Predator/
nano Predator-Key.pyChange this line to whatever you want:
PREDATOR_KEY_COMMAND = "notify-send 'Hello' 'Linux!'"Examples:
PREDATOR_KEY_COMMAND = "firefox"
PREDATOR_KEY_COMMAND = "kitty"
PREDATOR_KEY_COMMAND = "python /home/user/my-script.py"Run the script with sudo:
sudo python3 Predator-Key.pyWhen prompted, press your Predator key once. The script will:
- Automatically detect the correct input device (event4, event7, etc.)
- Detect the correct key code
- Save the configuration to
/tmp/predator_key.json - Run your command immediately
- Continue monitoring for future presses
After the first detection, the script uses the cached configuration and starts immediately:
sudo python3 Predator-Key.pyRun the script in the background (daemon mode) without blocking your terminal or startup scripts:
sudo python3 Predator-Key.py --run-backgroundThis is perfect for adding to window manager configs like bspwmrc, i3 config, or Hyprland:
# In your bspwmrc or similar
python3 /path/to/Predator/Predator-Key.py --run-backgroundThe script will fork into the background immediately and won't block the rest of your configuration.
If you need to re-detect (e.g., after hardware changes):
rm /tmp/predator_key.jsonDo not use ~ (tilde) shortcuts in paths for startup commands or .desktop files. Always use the full absolute path.
✅ Correct:
PREDATOR_KEY_COMMAND = "python /home/username/script.py"❌ Incorrect:
PREDATOR_KEY_COMMAND = "python ~/script.py"