~/mustakim
RSS

Writing / rust

heptix: the missing haptic feedback for Linux

heptix: the missing haptic feedback for Linux

Introducing heptix - it plays a sound when you tap the touchpad, scroll, click or type on Linux.

I wanted some feedback from my laptop (Dell XPS running NixOS). Tap-to-click gives you nothing you can feel or hear, so I never know if the tap actually registered. A MacBook gives you a little thud for it. I looked for something similar on Linux and couldn’t find anything that did what I wanted (more on that below), so Claude built it quickly and then I refined it for about a week.

To try it:

curl -fsSL https://raw.githubusercontent.com/mustakimali/heptix/main/install.sh | sh

How heptix protects your keystrokes

It asks how it should read your keyboard and touchpad, and the default is fine. Read the script first if you don’t like piping into a shell, I wouldn’t either. On NixOS a script can’t install a system service, so add the module from the flake:

imports = [ inputs.heptix.nixosModules.default ];
services.heptix.enable = true;

Then run heptix --demo to hear it. It plays a fake stretch of typing, clicking and scrolling and draws a keyboard, a mouse and a touchpad lighting up. It doesn’t read your devices, so it’s safe to try before you trust it with anything.

What it does

  • a soft thud when you tap or press the touchpad
  • a tick as you scroll with two fingers
  • a click for mouse buttons and a tick for the mouse wheel
  • mechanical keyboard sounds as you type, IBM Model M by default (the samples are from bucklespring)

It works on X11 and Wayland, because it reads the input devices through evdev instead of going through the display server. There is a small settings editor in the terminal, everything previews as you change it. There is an auto volume mode too, it gets quieter as the system volume goes up so it doesn’t shout over a call.

heptix: the missing haptic feedback for Linux

Counting stuff

Since it already sees every key and tap, I added an activity view (the picture at the top): when you type, how much you tap, and how far your fingers have travelled scrolling (in kilometres, there’s a switch for miles). There are also views for the busiest hours of the week and your most and least used keys.

heptix: the missing haptic feedback for Linux

heptix: the missing haptic feedback for Linux

These use made-up data, there’s a script in the repo that renders them. Mine is not as pretty.

It stores counters only. Totals per hour and how many times each key was pressed per day, never the order, the timing or any text. It’s a plain text file under ~/.local/state/heptix/, and you can turn it off or wipe it with one key.

Does something like this already exist?

Before building anything I (my agents) looked around, I’d much rather install something (open source) than write it. There is plenty for keyboard sounds:

ProjectKeyboard soundsTouchpad and mouse soundsWaylandHow it reads your keys
bucklespringModel Mnot mentionedneeds a non-default builddefault build needs X11; the raw-input build needs “special permissions” for /dev/input
Keyboard Soundsyesnot mentionedyes, via libevdevyour user must be in the input group
daktilotypewriter soundsnot mentionedlisted (with a footnote)not stated for Linux
Mechvibes (DX)yesnot mentionednot statedneeds the input group
Clicketyclackyesnot mentionedX11 onlyX11

I couldn’t find anything that plays a sound for a touchpad tap or scroll. The closest was an AUR package for the ThinkPad TrackPoint, which is a different thing. Real haptics are coming to Linux too, 6.18 gets haptic touchpad support in the HID layer, but you need a touchpad with a haptic motor for that, and mine doesn’t have one.

So what I wanted was touchpad and scroll feedback, on Wayland, without having to put myself in the input group. That last part matters. Anything in that group can read all keyboard input on the machine, including the login and lock screens, and so can every program I run. I wasn’t going to give that up for a thud.

What does the input group do? Every keyboard, mouse and touchpad shows up as a file under /dev/input/ (event0, event1 and so on), owned by root and the input group. Whoever can open those files gets the raw stream of key presses and movements, the same one your desktop gets. Your desktop opens them through systemd-logind, so normal programs can’t. Add your user to input and every program you run can read them, whichever window has focus. That’s also all a keylogger needs. Wayland stops apps from spying on each other’s windows, but this goes underneath it.

Keeping my keyboard to myself

Instead, heptix is split in two. A small reader service runs as its own heptix user, it’s the only thing that opens the input devices, and it has no network, no audio and a read-only system. My own heptix gets the events over a unix socket. The reader only talks to the exact root-owned heptix binary started by my own systemd --user, and it checks that again every two seconds. I’m not in the input group.

How heptix reads your input The input devices are read only by the reader service, which runs as its own heptix user. It sends events over a unix socket to your own heptix client, after checking it. Your other programs cannot open the devices or talk to the reader. /dev/input keyboard mouse touchpad reader service runs as its own user: heptix in the input group no network, no audio read-only system heptix client runs as you (systemd --user) no network at all plays the sounds counts your stats unix socket checked every 2s your other programs browser, editor, anything can't open refused not in the input group
Only the reader opens the input devices, and it only talks to your own heptix.

The client has no network either (systemd blocks everything except local unix sockets), so there is nowhere to send anything even if it wanted to. No analytics, no crash reports, no update check. The code doesn’t have a networking dependency to begin with.

It’s not bulletproof. The README lists what it doesn’t stop: a compromise of heptix itself, kernel exploits and root. And audible clicks tell anyone who can record your audio about your typing rhythm. But it’s a much smaller door than the input group.

Let’s not pretend I write the code, I supervise a very fast intern!

Claude wrote most of the code, same as with wnumbr. What it made cheap was the boring stuff I would normally skip: the systemd hardening, an installer tested in containers with real systemd on Debian, Ubuntu, Fedora and Arch (Alpine has no systemd, there it only checks that the installer refuses politely), a NixOS VM test for the module, a test that fakes a keyboard through /dev/uinput, and signed releases. The installer checks the signature when you have the GitHub CLI installed.

I’m responsible for the decisions that go into the architecture.

It’s GPL-2.0 and on GitHub. If a distro breaks or you want a sound added, open an issue.

M Mustakim Ali

I'm a Software Engineer living in London, UK. My passion is to make *very fast* software with great user experience and I have just got little better on this than I was yesterday.