Mapping Keys

The Problem

The Caps Lock key serves mainly as a source of annoyance, and receives far too much real estate relative to its use. However, the Esc key is quite useful (I'm primarily a Vim user), but is far too hard to reach. Currently, Éowyn has altered key settings to make life a bit easier. The Caps Lock key now acts like the Esc key.

Stuff that didn't work

I first tried this using the command

xmodmap -e `clear Lock' -e `keycode 0x42 = Escape'
but for some reason, it stopped working for one of my TeX files. Future me is pretty sure I put this in a file that isn't loaded by default on bash, but I can't remember. This will probably still work if you put this in the right file; maybe I'll test this later.

The Solution

  1. I installed the dconf-editor using
    sudo apt-get install dconf-tools
  2. I started the editor, and went to orggnomedesktopinput-sources
  3. At the bottom of the page, I saw two square braces with nothing in them. These braces are required.
  4. Within these braces, I added
    'caps:escape'
    to add the Caps Lock key as another Esc. The command you want to use needs to be enclosed in single quotes. If you want multiple options, they need to be comma separated. A full list of commands can be found by typing
    man 7 xkeyboard-config
  5. Exit out, and you're good to go!

With Cinnamon

On Cinnamon, which is what I'm currently using I used to use, the solution was a bit different, and I liked it a lot less. I thought the process would be similar, using some form of gnome-tweaks since Cinnamon is GNOME-based, but it was a fair bit messier.

Edit the file /etc/default/keyboard as superuser. There'll be a line with XKBOPTIONS="blah", where blah represents your current settings, most likely nothing. Just put the string caps:escape inside of those quotes and restart. That's it!

Update on XKB stuff

Yeehaw. On i3, things, uh, work a bit differently, since the normal tools I use are not easily available to me. Here's the entirety of the previous file:

XKBMODEL="pc105"
XKBLAYOUT="us"
XKBVARIANT=""
XKBOPTIONS="compose:ralt,caps:escape"

BACKSPACE="guess"

Update #2, with Arch Linux

Right, so here's an even easier solution! Just add the following line to your config:

setxkbmap -option compose:ralt,caps:escape
The only way I could get this to work is by adding it to my i3 config; I preceded it with exec_always --no-startup-id. This solution's a lot better since you don't have to edit those sensitive files yourself.

Arrow Keys

I really felt the need to add this at a later date. Why, you might ask? Sheer fear (which is also what I felt writing half the content on this website).

To be kinda vulnerable on the internet: like a lot of folks, when I'm stressed, I like to change things, often a bit impulsively. This could be a haircut, reflashing my computer with a new distro, clean up/decorate my work space, etc. And these actions all have their own consequences.

This time, I disabled my arrow keys, using xmodmap, which I talked about earlier on this page. I guess I thought I needed to learn Vim and Emacs (since the default for terminals is Emacs) keybindings. Based on what another user said on StackExchange, I ran the command

xmodmap -e 'keycode 116='; xmodmap -e 'keycode 113='; xmodmap -e 'keycode 114='
Initially, I panicked, since I couldn't reverse it, and there are unanswered comments below the accepted answer (this entry is dated 10/18/20) asking how to undo the action. However, somehow, it, um, undid itself? I'm not entirely sure what's up with that. But we'll see, I guess.