caps2esc:logo4alt

Interception tools plugin that maps caps->{esc,ctrl} and logo<->alt
git clone git://git.deurzen.net/caps2esc:logo4alt
Log | Files | Refs | README | LICENSE

README.md (5464B)


      1 # caps2esc
      2 
      3 _Transforming the most useless key **ever** in the most useful one._
      4 <sub>_For vi/Vim/NeoVim addicts at least_.</sub>
      5 
      6 <a href="http://www.catonmat.net/blog/why-vim-uses-hjkl-as-arrow-keys/">
      7     <img src="http://www.catonmat.net/images/why-vim-uses-hjkl/lsi-adm3a-full-keyboard.jpg" alt="ADM-3A terminal">
      8 </a>
      9 
     10 ## What is it?
     11 
     12 - **Put what's useless in its place**
     13   <sub>_By moving the CAPSLOCK function to the far ESC location_</sub>
     14 - **Make what's useful comfortably present, just below your Pinky**
     15   <sub>_By moving both ESC and CTRL functions to the CAPSLOCK location_</sub>
     16 
     17 ## Why?!
     18 
     19 Because CAPSLOCK is just "right there" and making it CTRL when key-chording and
     20 ESC when pressed alone is quite handy, specially in vi.
     21 
     22 ## Dependencies
     23 
     24 - [Interception Tools][interception-tools]
     25 
     26 ## Building
     27 
     28 ```text
     29 $ git clone https://gitlab.com/interception/linux/plugins/caps2esc.git
     30 $ cd caps2esc
     31 $ cmake -B build -DCMAKE_BUILD_TYPE=Release
     32 $ cmake --build build
     33 ```
     34 
     35 ## Execution
     36 
     37 ```text
     38 caps2esc - transforming the most useless key ever in the most useful one
     39 
     40 usage: caps2esc [-h | [-m mode] [-t delay]]
     41 
     42 options:
     43     -h        show this message and exit
     44     -t        delay used for key sequences (default: 20000 microseconds)
     45     -m mode   0: default
     46                  - caps as esc/ctrl
     47                  - esc as caps
     48               1: minimal
     49                  - caps as esc/ctrl
     50               2: useful on 60% layouts
     51                  - caps as esc/ctrl
     52                  - esc as grave accent
     53                  - grave accent as caps
     54 ```
     55 
     56 `caps2esc` is an [_Interception Tools_][interception-tools] plugin. A suggested
     57 `udevmon` job configuration (check the [_Interception Tools_
     58 README][interception-tools] for alternatives) is:
     59 
     60 ```yaml
     61 - JOB: intercept -g $DEVNODE | caps2esc | uinput -d $DEVNODE
     62   DEVICE:
     63     EVENTS:
     64       EV_KEY: [KEY_CAPSLOCK, KEY_ESC]
     65 ```
     66 
     67 For more information about the [_Interception Tools_][interception-tools], check
     68 the project's website.
     69 
     70 ## Mouse/Touchpad Support
     71 
     72 After _Interception Tools_ 0.3.2, `caps2esc` can observe (or replace) mouse
     73 events. An example configuration taken from my laptop:
     74 
     75 ```yaml
     76 SHELL: [zsh, -c]
     77 ---
     78 - CMD: mux -c caps2esc
     79 - JOB: mux -i caps2esc | caps2esc | uinput -c /etc/interception/keyboard.yaml
     80 - JOB: intercept -g $DEVNODE | mux -o caps2esc
     81   DEVICE:
     82     LINK: /dev/input/by-path/platform-i8042-serio-0-event-kbd
     83 - JOB: intercept $DEVNODE | mux -o caps2esc
     84   DEVICE:
     85     LINK: /dev/input/by-path/platform-i8042-serio-4-event-mouse
     86 ```
     87 
     88 For more information on the topic, check the [_Interception Tools_
     89 README][interception-tools] about usage of the `mux` tool and hybrid virtual
     90 device configurations.
     91 
     92 ## Installation
     93 
     94 ### Archlinux
     95 
     96 It's available from [community](https://archlinux.org/packages/community/x86_64/interception-caps2esc/):
     97 
     98 ```text
     99 $ pacman -S interception-caps2esc
    100 ```
    101 
    102 ### Void Linux
    103 
    104 ```text
    105 $ xbps-install -S caps2esc
    106 ```
    107 
    108 ### Ubuntu ([independent package][ubuntu])
    109 
    110 ```text
    111 sudo add-apt-repository ppa:deafmute/interception
    112 sudo apt install interception-caps2esc
    113 ```
    114 
    115 <sub>For debian and other derivatives you can download directly at https://launchpad.net/~deafmute/+archive/ubuntu/interception/+packages.</sub>
    116 
    117 [ubuntu]: https://gitlab.com/interception/linux/tools/-/issues/38
    118 
    119 ## Caveats
    120 
    121 As always, there's always a caveat:
    122 
    123 - `intercept -g` will "grab" the detected devices for exclusive access.
    124 - If you tweak your key repeat settings, check whether they get reset.
    125   Please check [this report][key-repeat-fix] about the resolution.
    126 
    127 ## History
    128 
    129 I can't recall when I started using CAPSLOCK as both ESC and CTRL but it has
    130 been quite some time already. It started when I was on OS X where it was quite
    131 easy to achieve using the [Karabiner][], which already provides an option to
    132 turn CTRL into ESC/CTRL (which can be coupled with OS X system settings that
    133 turn CAPSLOCK into CTRL).
    134 
    135 Moving on, permanently making Linux my home, I searched and tweaked a similar
    136 solution based on [xmodmap][] and [xcape][]:
    137 
    138 - <https://github.com/alexandre/caps2esc>
    139 
    140 It's a simple solution but with many annoying drawbacks I couldn't stand in the
    141 end:
    142 
    143 - It resets any time a device change happens (bluetooth, usb, any) or the
    144   laptop lid is closed or when logging off and needs to be re-executed.
    145 - It depends on [X][]. Doesn't work on TTY (bare terminal based machine,
    146   CTRL-ALT F2, etc).
    147 
    148 Meanwhile on Windows land, I had a definitive solution based on my
    149 [Interception library][interception] that always works perfectly, no hiccups.
    150 
    151 It made me envy enough, so I ported the
    152 [Windows Interception caps2esc][caps2esc-windows] sample to Linux based upon
    153 the [_Interception Tools_][interception-tools].
    154 
    155 ## License
    156 
    157 <a href="https://gitlab.com/interception/linux/plugins/caps2esc/blob/master/LICENSE.md">
    158     <img src="https://upload.wikimedia.org/wikipedia/commons/thumb/0/0b/License_icon-mit-2.svg/120px-License_icon-mit-2.svg.png" alt="MIT">
    159 </a>
    160 
    161 Copyright © 2017 Francisco Lopes da Silva
    162 
    163 [caps2esc-windows]: https://github.com/oblitum/Interception/blob/master/samples/caps2esc/caps2esc.cpp
    164 [karabiner]: https://pqrs.org/osx/karabiner/
    165 [xmodmap]: https://www.x.org/releases/X11R7.7/doc/man/man1/xmodmap.1.xhtml
    166 [xcape]: https://github.com/alols/xcape
    167 [x]: https://www.x.org
    168 [interception]: https://github.com/oblitum/Interception
    169 [interception-tools]: https://gitlab.com/interception/linux/tools
    170 [key-repeat-fix]: https://github.com/oblitum/caps2esc/issues/1