Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

When running X I use a .xmodmaprc to remap certain keys thusly:

! Make it so that both Caps Lock and Escape do Escape
clear Lock
keysym Caps_Lock = Escape
! Remap the menu key as Compose
keysym Menu = Multi_key

How can I accomplish the same things on the console?

update

In addition to the partial solution given in my answer, I've learned that the console maps CTRL-. to Compose. So I may be able to get used to that. Setting up the Menu key as Compose is not so easily done, as there are a ton of nul-assigned keycodes and no obvious contender for an alternate name for Menu.

I've also realized that the compose bindings themselves are much more limited than what I'm used to under X, and that most of the special characters I use frequently are not there. Perhaps there is a utility that will translate X-syntax compose bindings into something that loadkeys can read?

share|improve this question
    
Traditionally: with loadkeys. I think nowadays you can get the Linux console to read the X configuration, but I don't know how this works. –  Gilles Feb 19 '11 at 14:13
add comment

2 Answers

You'll have to edit your console keymap. On my console, I have mapped Escape to Caps Lock and Caps Lock to Escape. Here's how it works.

  1. First you need to find your keymap. I use the standard US layout. On my system, it is located under /usr/share/keymaps/i386/qwerty/us.map.gz.
  2. Make a copy of the file under a new name, for example us-nocaps.map.gz.
  3. Unpack the file and open it in a text editor: gunzip us-nocaps.map.gz && vim us-nocaps.map
  4. Change the mappings in the file to your liking, for example I had keycode 58 = Caps_Lock which I changed to keycode 58 = Escape.
  5. Gzip the file and load it: gzip us-nocaps.map && loadkeys us-nocaps.

One more thing: You'll probably have to configure your distribution somehow to make sure the new keymaps always gets loaded on boot, otherwise you'll have to load your keymap manually with loadkeys all time. How you do that depends on what distribution you're using.

share|improve this answer
add comment

With some help from Cedric, I've discovered that Ubuntu hasn't installed the keymaps where $ man loadkeys says they are supposed to be (/usr/share/keymaps). This is a brand-new install, so maybe I just need to install a package in order to get keymaps other than the one I selected during installation.

In lieu of pursuing that angle, and in an effort to make the solution a bit more robust and convenient, I'm doing this:

    $ sudo dumpkeys | sed 's/CtrlL_Lock/Escape/' | sudo loadkeys

Although I'm a bit confused as to why Cedric's system uses Caps_Lock for caps lock and mine uses CtrlL_Lock, it is working regardless.

share|improve this answer
    
That's interesting, I didn't know there where differences across distributions with those keymaps. Personally I use Gentoo, the keymaps are from the sys-apps/kbd-1.15 package. –  Cedric Feb 20 '11 at 15:11
1  
As of Ubuntu 10.04, the keymaps are in the console-data package. They're not installed by default. You can find out what package installs files in /usr/share/keymaps by running apt-file search /usr/share/keymaps. –  Gilles Feb 20 '11 at 19:55
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.