Getting Started with GNU/Linux
What is Linux? Linux is an open-source operating system, which means its source code is freely …
read moreI recently finished a small tool I developed for a very specific problem: using the inexpensive MKESPN K806 mini-keypad on Linux when there isn’t reliable native support. I was given this keypad some time ago but, without a stable mapping tool, I couldn’t put it to use—until I had some time to research and build a solution. If you own this keypad or a similar one, this will be useful; the code is published so it can be adapted to other models.
The utility combines two parts: a daemon that listens to the physical device and executes actions, and a small graphical application (Tkinter). It aims to be simple, reliable and easy to adapt to your workflow. The full code and instructions are available on GitHub for anyone who wants to use it or contribute.
The tool was developed and tested mainly on GNOME with X11 on Ubuntu. Other setups (for example GNOME on Wayland, KDE, Sway or other compositors) may require adjustments and some features—like key injection via xdotool
—might not work or may behave differently.
Although it was born for the MKESPN K806, it can work with similar keypads that expose EV_KEY events; support for other models is experimental and not guaranteed.
The MKESPN K806 has no official Linux support and the generic tools I tested either didn’t persist mappings reliably between sessions or were flaky. This tool provides:
~/.keymap.json
)./dev/input/by-id/...
) so mappings survive device renaming between reboots.evdev
and executes configured actions (key combos using xdotool
or shell commands).The project actually contains two components:
mini_keypad_daemon.py
: a background process that opens the device, grabs events and runs mapped actions.mini_keypad_mapper.py
: a Tkinter app to create, edit, test and save key mappings.Minimum dependencies
sudo apt update
sudo apt install -y python3 python3-evdev xdotool python3-tk
Clone the repo and put the scripts in a directory of your choice, for example ~/.local/bin
.
Create your ~/.keymap.json
or use the UI to generate one (the app includes suggested defaults).
Configuration format (example)
{
"device_path": "/dev/input/by-id/usb-MKESPN_K806-event-kbd",
"enabled": true,
"mapping": {
"116": { "kind": "combo", "value": "Ctrl+Alt+T" },
"117": { "kind": "command", "value": "firefox" }
}
}
Note: the keys in the mapping
object must be event codes (from evdev
), and supported kind
values are combo
(translated to xdotool key ...
) and command
which runs a shell command.
To run the daemon automatically at login it’s recommended to configure it as a user systemd service. Below is an example unit file and some useful instructions to install, start and debug it.
Example user unit file: ~/.config/systemd/user/mkespn-k806.service
[Unit]
Description=MKESPN K806 Keymap Daemon
After=graphical-session.target
[Service]
ExecStart=/usr/bin/python3 /home/USER/mini_keypad_daemon.py
Restart=always
Environment=DISPLAY=:1
Environment=XAUTHORITY=/home/USER/.Xauthority
Environment=PATH=/usr/local/bin:/usr/bin:/bin:/home/USER/bin:/home/USER/.local/bin
[Install]
WantedBy=default.target
Replace USER
with the account that will run the daemon. Then you can install and manage it like this:
~/.config/systemd/user/mkespn-k806.service
.
systemctl --user daemon-reload
systemctl --user enable --now mkespn-k806.service
systemctl --user status mkespn-k806.service
journalctl --user -u mkespn-k806.service -f
systemctl --user restart mkespn-k806.service
).xdotool
does not work on pure Wayland; look for compositor-specific alternatives in those environments.The daemon needs to read events from /dev/input/event*
. Avoid running the service as root in production; instead use one of these options:
/etc/udev/rules.d/99-mini-keypad.rules
with something like:
KERNEL=="event*", ATTRS{name}=="MKESPN K806", GROUP="input", MODE="0660"
After creating the rule reload udev: sudo udevadm control --reload-rules && sudo udevadm trigger
.
Input group: add the user to the group that has access to input devices: sudo usermod -aG input $USER
and log out/in.
Root for debugging: if you use root for testing do it temporarily and avoid that practice on production machines.
Here are some typical shortcuts you can map. Copy the value
into the corresponding field in your profile (combo
or command
):
Action | Type | Example (value) |
---|---|---|
Lock screen | combo | Super+L |
Open browser | command | firefox |
Launch VS Code | command | code |
Interactive screenshot | command | gnome-screenshot -i |
xdotool
and adapt combo execution to each compositor.The project is published under the MIT license (change if you prefer another). Contributions are welcome: open issues with reproducible information, PRs with improvements or discussions about compatibility. Note in the repo if you prefer a different license or restrictions.
The GitHub repo contains the full code, issues and a short guide. This project was born from a practical need: to make a cheap mini-keypad reliably usable in my daily workflow. If the tool interests you, try the UI first to generate ~/.keymap.json
and, if it fits, run the daemon as a service. If you have improvements, ideas or similar devices, contribute on GitHub. Happy Coding!
That may interest you
What is Linux? Linux is an open-source operating system, which means its source code is freely …
read moreIn the last chapter, we covered the basics of Linux, the most commonly used user-friendly …
read moreWhat separates an average developer from an expert isn’t the IDE or the language—it’s how well they …
read moreConcept to value