dual-function-keys

ever since i heard that people bind their capslock key to control, i've been thinking a lot more about other keyboard modifications that i could make. right now, i just use a QWERTY international keyboard with dead keys. on top of the layout, i've added just three modifications through a plugin for interception-tools, which i'd like to show you today

note: i've only tested this on arch/artix linux. it should, however, work on most linux distros

tools

interception-tools is a cool bit of software that allows you to intercept input devices and modify their signals programmatically before sending them along their way as normal. this results in a setup that works not just in x11, but also in wayland, and even a pure console environment

interception-tools

the programmatic modifications that can be made are actually handled by plugins, of which there are a fair number. this post will go over the dual-function-keys plugin. the following link is to this plugin, but the repository this one is listed under also features several other plugins

dual-function-keys

if you only want the capslock mod i use, check out caps2esc instead, as its comparatively simpler. here's a weblink to a tutorial for that, and to its repo:

caps2esc tutorial

caps2esc repository

on arch/artix, installing the tools is a simple:

pacman -S interception-tools interception-dual-function-keys

modifications

my configuration uses three modifications:

a double tap and hold will be a hold for the tap action, so i don't have to spam the shift key to remove text

configuration

all of our modifications will be under /etc/interception. both tools have the capacity to be far more complex than shown here, so its worth reading their respective man pages and/or github READMEs

dual-function-keys

first, create dual-function-keys/mappings.yaml, and add the following:

MAPPINGS:
  - KEY: KEY_CAPSLOCK
    TAP: KEY_ESC
    HOLD: KEY_LEFTCTRL

  - KEY: KEY_LEFTSHIFT
    TAP: KEY_BACKSPACE
    HOLD: KEY_LEFTSHIFT

  - KEY: KEY_RIGHTSHIFT
    TAP: KEY_DELETE
    HOLD: KEY_RIGHTSHIFT

interception-tools

next, we'll create a udevmon.d/config.yaml file, with the following contents:

- JOB: intercept -g $DEVNODE | dual-function-keys -c /etc/interception/dual-function-keys/mappings.yaml | uinput -d $DEVNODE
  DEVICE:
    EVENTS:
      EV_KEY: [KEY_CAPSLOCK, KEY_RIGHTSHIFT, KEY_LEFTSHIFT]

startup

start udevmon and it should work immediately, no reboot or relog should be needed

systemctl enable udevmon
systemctl start udevmon

note: init system support varies:

openrc init script

conclusion

as mentioned earlier, this is just my own very basic setup. the official documentation for these tools has far more information both on how these tools work and how to configure them, so check them out

metadata

author: snit

created: 2024-03-08

updated: 2024-03-19