You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

127 lines
4.2 KiB

1 year ago
  1. ---
  2. title: Interception Vimproved
  3. next: /docs/selfhosting/nextcloud
  4. ---
  5. ### Setting up Interception Vimproved on Debian Bookworm
  6. I started learning vim few months ago and wanted to try vim key bindings like shortcuts on my laptop after trying a mechanical hackable keyboard.
  7. [Interception Vimproved](https://github.com/maricn/interception-vimproved) is a plugin for [interception-tools](https://gitlab.com/interception/linux/tools) which combines both caps2esc and space on hold work as special ```fn``` key.
  8. This blog post shows how to setup [interception-vimproved](https://github.com/maricn/interception-vimproved) using interception-tools on Debian Bookworm.
  9. #### Step 1: Dependencies
  10. Installing Dependencies to build interception-vimproved on Debian Bookworm GNU/Linux
  11. ```bash
  12. $ sudo apt install interception-tools meson libyaml-cpp-dev cmake
  13. ```
  14. interception-tools is a small set of tools for input events of devices,that can be used to customize the behaviour of input keyboard mappings.
  15. The advantage of interception-tools operates at lower level compared to xmodmap by using libevdev and libudev.
  16. #### Step 2: Clone & Build
  17. Clone interception-vimproved repository and build
  18. ```bash
  19. $ git clone "https://github.com/maricn/interception-vimproved"
  20. $ cd interception-vimproved
  21. $ sudo make install
  22. ```
  23. Clone the git repository and change the directory, and then launch a ```make install``` command to build.
  24. #### Step 3: Configuration
  25. Create a new file called udevmon.yaml in /etc/interception and paste the following contents into the file /etc/interception/udevmon.yaml
  26. ```bash
  27. - JOB: "interception -g $DEVNODE | interception-vimproved /etc/interception-vimproved/config.yaml | uinput -d $DEVNODE"
  28. DEVICE:
  29. NAME: ".*((k|K)(eyboard|EYBOARD)).*"
  30. ```
  31. ```udevmon.yaml``` is like a job specification for ```udevmon```,specifying that it matches with ```(k|K)(eyboard|EYBOARD))``` input device.
  32. {{< callout type="info" >}}
  33. I haven't tested this for an External Keyboard Input device,but works fine for the built-in keyboard of the laptop.
  34. {{< /callout >}}
  35. #### Step 4: Reload udevmon
  36. Reload udevmon using systemctl
  37. ```bash
  38. $ sudo systemctl restart udevmon
  39. ```
  40. #### Hack around the config
  41. To change any keybindings or to add new mappings the config file is present in config.yaml located in /etc/interception-vimproved/ when a ```sudo make install``` is launched the config file is
  42. copied to ```/etc/interception-vimproved/config.yaml```.
  43. my config.yaml has the below shortcuts
  44. ```bash{filename="/etc/interception-vimproved/config.yaml"}
  45. - intercept: KEY_CAPSLOCK
  46. ontap: KEY_ESC
  47. onhold: KEY_LEFTCTRL
  48. - intercept: KEY_ENTER
  49. # not necessary: ontap: KEY_ENTER is inferred if left empty
  50. onhold: KEY_RIGHTCTRL
  51. # this is a layer. hold space (onhold) contains several remappings
  52. - intercept: KEY_SPACE
  53. onhold:
  54. # special chars
  55. - from: KEY_E
  56. to: KEY_ESC
  57. # alternative syntax
  58. - {from: KEY_D, to: KEY_DELETE}
  59. - {from: KEY_B, to: KEY_BACKSPACE}
  60. # vim home row
  61. - {from: KEY_H, to: KEY_LEFT}
  62. - {from: KEY_J, to: KEY_DOWN}
  63. - {from: KEY_K, to: KEY_UP}
  64. - {from: KEY_L, to: KEY_RIGHT}
  65. # vim above home row
  66. - {from: KEY_Y, to: KEY_HOME}
  67. - {from: KEY_U, to: KEY_PAGEDOWN}
  68. - {from: KEY_I, to: KEY_PAGEUP}
  69. - {from: KEY_O, to: KEY_END}
  70. # number row, to F keys
  71. - {from: KEY_1, to: KEY_F1}
  72. - {from: KEY_2, to: KEY_F2}
  73. - {from: KEY_3, to: KEY_F3}
  74. - {from: KEY_4, to: KEY_F4}
  75. - {from: KEY_5, to: KEY_F5}
  76. - {from: KEY_6, to: KEY_F6}
  77. - {from: KEY_7, to: KEY_F7}
  78. - {from: KEY_8, to: KEY_F8}
  79. - {from: KEY_9, to: KEY_F9}
  80. - {from: KEY_0, to: KEY_F10}
  81. - {from: KEY_MINUS, to: KEY_F11}
  82. - {from: KEY_EQUAL, to: KEY_F12}
  83. # xf86 audio
  84. - {from: KEY_M, to: KEY_MUTE}
  85. - {from: KEY_COMMA, to: KEY_VOLUMEDOWN}
  86. - {from: KEY_DOT, to: KEY_VOLUMEUP}
  87. # mouse navigation
  88. - {from: BTN_LEFT, to: BTN_BACK}
  89. - {from: BTN_RIGHT, to: BTN_FORWARD}
  90. ```
  91. [Interception-tools](https://tracker.debian.org/pkg/interception-tools) is packaged on debian,interception-vimproved is not,
  92. that is the reason we are building the source of interception-vimproved,hopefully i'll try packaging it !.
  93. Arch has interception-tools already packaged here is the [link](https://wiki.archlinux.org/title/Interception-tools)
  94. ```bash
  95. :wq #until next time
  96. ```