Living my Fullest on Home Row

Gaanu/Linux interception-tools Keyboard_hacking X201



What's this?

Disrupt Inertia

I was using Meta (CAPS being remapped) as my modifier for all WMs I use,
problem was when using Vim I have to travel a lot for reaching ESC

Going through vim fandom I'm no where satisfied with the alternatives,
Alt placement strains me more than CTRL
(exception looking at my X201's funky FN key )

Went with Ctrl-c, there were many drawbacks with this one.
Real bummer was shift+i to insert in multiple lines
plus it's not simple as tapping a single key.
Also I don't want to compromise Meta CAPS remap.

I was lazy relying on my cheap 60% keyboard's (Bnne Pro)
tap function untill quarantine (my KB was struck in my dorm)

Double Frustated me :/



(this should work regardless of X11 or wayland)


Tested on MX-linux, Artix, Manjaro (all running kernal > 5.6)
Dependencies, I find names are quite different on Debian-based

$ apt-file search libevdev-uinput.h
libevdev-dev: /usr/include/libevdev-1.0/libevdev/libevdev-uinput.h 

$ apt-file search libudev.h
libudev-dev: /usr/include/libudev.h       

$ apt install libevdev-dev libudev-dev libyaml-cpp-dev cmake

and follow build instructions

AUR (simple as ever), packages interception-tools dual-function-keys

Getting started

Figuring right input device,

$ cat /dev/input/event<x>
/* in my case platform-i8042-serio-0-event-kbd is linked to event3 */

pressing keys for the right input device will stdout some weird characters so one can be sure.

intercept -g /dev/input/event<x> | uinput -d /dev/input/event<x>
virtual device (uinput) will deny reading unless
the user is in input group or running uinput as root.
here's the caveat intercept hijacks the input so password cannot be typed..
workaround would be permitting uinput to run as root without password
as I'm using doas
echo "permit nopass :hisacro cmd uinput" >> /etc/doas.conf
should be similar for sudo
(with hard syntax gimmicks & editing with visudo..)

note : use udevmon instead see below,
if it's just for testing make sudo persist on shell
so typing passwd is avoided

Succeding above, it's pretty much done by piping the hijacked input
into Dual-function-keys plugin before it goes to virtual device

Dual-function-keys need yaml config file, (simple syntax for layman)


    - KEY: KEY_TAB
      TAP: KEY_TAB

      TAP: KEY_ESC


If everything goes well this should work

$ intercept -g /dev/input/event<x> | dual-function-keys -c /path/to/tapping.yaml | sudo uinput -d /dev/input/event<x>` 

As udevmon is included in interception-tools,
it helps combining these also supports config for multiple devices,
auto reads files under /etc/interception/udevmon.d/best_tap.yaml

- JOB: "intercept -g /dev/input/event3 | dual-function-keys -c ~/.myscripts/tapping.yaml |  uinput -d /dev/input/event3"

now $ udevmon is all you need

If you're planning to run udevmon as init script,
sample systemd.service is provided beware
this affects all users if you're on shared desktop.
(personally I prefer udevmon on my WM's startup script)


$ uinput -p -d /dev/input/event<x> will list all the keys

Use evtest instead of xev to check the Event_codes

Most of the packages share [shift] + ctrl + tab to toggle back and forth
in addition if alt or ctrl overrides with default maps,
use shift + ctrl + some_key


My UseCase

Window Managers

i3, herbstluftwm (heavy on Meta as mod which is CAPS_hold)
sudo tiling shortcuts on xfce. (account on family desktop)


nethack - close to few hundreds of YASD in a week
remapped few uppercases to CTRL
(I got into Vi from nethack when looking
for similar key-bind editor still miss yubn)

vim - all other options makes much sense
notably, Tab + hjkl moves from insert to normal in resp. direction

Terminal Tabs (unpopular but I highly relay on them)
with tab_hold + num to navigate

mutt - only mail client.

Image editor

Gimp - More than 5 hrs in a day (cleaning manga),
modified shortcuts to relay on tab_hold
Mtpaint - Pixel art, not as heavy on shortcuts compared to GIMP


firefox, (remember holding ; is ctrl now)

tab_hold + D		focus address bar, 
shift + ; + tab 	previous tab 
; + tab          	next tab 
; + t 			new tab
; + w			close tab	
; + u 			web page source code

Luakit as secondary.


Using it for almost 3 months, this has been hard encoded into my muscle memory
to the point I cannot work without it :)

The lag isn't humanly noticeable (don't trust me see it for yourselves)


Any suggestions, unique keybinds, stories, improvements are much welcome
(and fellow hacker with long unix beard tips for getting similar function on OBSD)

Tinker around with multiple devices, Tap timings, extra modifier on home row.. endless
Happy input Hacking!