swap keys (caps and escape) in virtual console

I can swap caps and escape keys successfully for X in .xinitrc using
Code:
setxkbmap -option caps:swapescape

But sometimes I don't want or need to login to X (and I don't run a login manager like slim... I just 'startx' when I want to load X), so how can I accomplish the same for the virtual console, so that I can be a happy vim user straight after booting up?
TIA
 
Assuming you are using the default vt console, first make a copy of your keymap.
For mine, that would be cp /usr/share/vt/keymaps/de.acc.kbd /usr/share/vt/keymaps/de_myspecial.acc.kbd
Now edit your new keymap to your likings. The keymap files are read-only, so either make your file writable or force writing when you're in vim.

I suggest keeping your keymap file open in vim on one console and switch to another console to test your changes there kbdcontrol -l de_myspecial.acc
A good idea is to yank the lines before editing them and document your changes. It's otherwise easy to lose track, when editing the lines in place.
 
That worked great, thank you. For some reason, I had to make my copy of the us.kbd keymap in the same folder. When I tried saving it in /etc/ and loading from there, I got an error. Also, still had to use setxkbmap in .xinitrc for X environment. Thanks again!
 
Back
Top