121 lines
2.7 KiB
Markdown
121 lines
2.7 KiB
Markdown
# Keyboard Input Blocker
|
|
|
|
A graphical application for Linux that toggles keyboard input blocking with a
|
|
single button. Perfect if your toddler likes to press a lot of buttons during
|
|
video calls.
|
|
|
|
## Features
|
|
|
|
- Simple one-button toggle interface built with PyQt6
|
|
- Disables/enables all keyboard input at the system level
|
|
- Status indicator showing current state
|
|
- Works on Wayland and X11
|
|
|
|
## Requirements
|
|
|
|
- Python 3.7+
|
|
- PyQt6
|
|
- evdev (Linux kernel input device library)
|
|
|
|
## Installation
|
|
|
|
### 1. Install dependencies
|
|
|
|
**On Ubuntu/Debian:**
|
|
|
|
```bash
|
|
sudo apt-get install python3 python3-pip libevdev-dev
|
|
pip install -r requirements.txt
|
|
```
|
|
|
|
**On Fedora:**
|
|
|
|
```bash
|
|
sudo dnf install python3 python3-pip libevdev-devel
|
|
pip install -r requirements.txt
|
|
```
|
|
|
|
**On Arch:**
|
|
|
|
```bash
|
|
sudo pacman -S python3 libevdev python-pyqt6 python-evdev
|
|
```
|
|
|
|
### 2. Run the application
|
|
|
|
The application requires elevated privileges to access input devices:
|
|
|
|
```bash
|
|
sudo -E python3 kb-block.py
|
|
```
|
|
|
|
Or make it executable:
|
|
|
|
```bash
|
|
chmod +x kb-block.py
|
|
sudo -E ./kb-block.py
|
|
```
|
|
|
|
## Usage
|
|
|
|
1. Launch the application with `sudo -E`
|
|
2. Click **"Block Keyboard"** to disable all keyboard input
|
|
- The button turns red and shows **"Unblock Keyboard"**
|
|
- Status shows "Keyboard BLOCKED ⚠"
|
|
3. Click **"Unblock Keyboard"** to re-enable keyboard input
|
|
- The button returns to normal
|
|
- Status shows "Keyboard enabled ✓"
|
|
|
|
**Note:** When keyboard is blocked, you'll need to use:
|
|
|
|
- Mouse to unblock via the button
|
|
- External input devices (if available)
|
|
- Or kill the process from another terminal: `sudo killall -9 python3` (or the
|
|
specific PID)
|
|
|
|
## How it Works
|
|
|
|
The application uses the `evdev` library to grab input devices at the kernel level:
|
|
|
|
- `grab()` - Prevents the keyboard from sending any events
|
|
- `ungrab()` - Restores keyboard input
|
|
|
|
This works with both X11 and Wayland display servers.
|
|
|
|
## Permissions Note
|
|
|
|
The application requires `sudo` because it needs to directly access
|
|
`/dev/input/event*` devices.
|
|
|
|
If you want to run without `sudo`, you can add your user to the `input` group:
|
|
|
|
```bash
|
|
sudo usermod -a -G input $USER
|
|
# Log out and back in for the change to take effect
|
|
```
|
|
|
|
However, this is less secure as it grants all users in the input group broad
|
|
input device access.
|
|
|
|
## Troubleshooting
|
|
|
|
### No keyboard device found
|
|
|
|
- Ensure you're running with `sudo -E`
|
|
- Check that keyboard input devices exist: `ls -la /dev/input/event*`
|
|
|
|
### Permission denied"
|
|
|
|
- Run with `sudo -E`
|
|
- Or add your user to the input group (see Permissions Note above)
|
|
|
|
### Keyboard still responds
|
|
|
|
- Multiple keyboard devices may exist; the app grabs the primary one
|
|
- Try unblocking and re-blocking
|
|
|
|
## License
|
|
|
|
This project is licensed under the Zlib license (see [LICENSE](LICENSE) file for
|
|
more information).
|