How to install Interception Tools on Pop!_OS

Interception Tools

What is Interception Tools?

It's a software that lives between the kernel and the X server. It processes the input events and can modify it.

Why is it useful?

You can modify the keyboard layout, or make the keyboard act like a mouse, or...

Why did I get interested in it?

Pressing Esc is hard. Pressing ctrl is hard. I use vim. 

Why did I write this post? 

Because I'm sure I will be coming back to this and the main developers apparently hate Ubuntu!

Installation

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

I also needed to install the boost libraries:

sudo apt install libboost-all-dev

Now, clone the Interception Tools repo, compile and install it:

git clone https://gitlab.com/interception/linux/tools
cd tools
mkdir build
cd build
cmake ..
make
sudo make install

Now, install the Capslock to Escape plugin for it:

git clone https://gitlab.com/interception/linux/plugins/caps2esc
cd caps2esc
mkdir build
cd build
cmake ..
make
sudo make install

Now, we need to configure Interception Tools to use the caps2esc plugin:

sudo mkdir -p /etc/interception/udevmon.d/
sudo vim /etc/interception/udevmon.d/c2e.yaml

And copy the following in it:

- JOB: intercept -g $DEVNODE | caps2esc | uinput -d $DEVNODE
DEVICE:
LINK: /dev/input/by-id/usb-Cooler_Master_Technology_Inc._MasterKeys_S-event-kbd

In this case I am referring to my exact keyboard. You can find your keyboard using:

ls /dev/input/by-id | grep kbd

My laptop keyboard was under:

ls /dev/input/by-path | grep kbd

That being said, it is probably possible to use a more general config like this:

- JOB: "intercept -g $DEVNODE | caps2esc | uinput -d $DEVNODE"
  DEVICE:
    EVENTS:
      EV_KEY: [KEY_CAPSLOCK, KEY_ESC]

Now that the configuration is done we need to add udevmon to the services so that it starts with the system.

Open this file:

sudo vim /etc/systemd/system/udevmon.service

and copy the following in it:

[Unit]
Description=udevmon
Wants=systemd-udev-settle.service
After=systemd-udev-settle.service

[Service]
ExecStart=/usr/bin/nice -n -20 /usr/local/bin/udevmon 

[Install]
WantedBy=multi-user.target

Make sure that the address for `udevmon` is correct:

which udevmon

Make sure to enable this service:

sudo systemctl enable --now udevmon

Also make sure to add the user to all the groups that are relevant. (not sure which one is relevant):

sudo usermod -a -G sudo $USER
sudo gpasswd -a $USER input
usermod -a -G plugdev $USER

Usage

After a reboot, the Esc key acts like CapsLock key. And the CapsLock key acts like both the Esc key and the Ctrl key. If you tap the CapsLock key, it will register as Esc, and if you hold it down and press another key it will register it as Ctrl and perform a combination. So, for example CapsLock+C will copy, but tapping the CapsLock key, will be just an Esc event.

Comments