Because I now and then need to use scandinavian letters despite using US Dvorak as my layout, I would like to use Caps Lock as a compose key. (I don't need Caps Lock at all, I'm not a forum troll)
How would one accomplish this?
Using Linux Mint 17 with xfce, if that makes a difference.
For the record, I am the only user of this PC, and would prefer to have this be the system default, mainly in xorg, but also in tty if that's not too much drudgery.
Best Answer
X11 (classic)
Run the program
xev
from a terminal to see the keycode sent by the CapsLock key. That's the number just afterkeycode
on the third line from theKeyPress event
line corresponding to pressing the key. On a PC, the keycode is 66.Create a file called
.Xmodmap
in your home directory and add the lineMode_switch
is the weird name that X11 gives to Compose.clear Lock
is necessary to avoid the key occasionally acting like Caps Lock even though it isn't Caps Lock (Lock
is the Caps Lock modifier, and some applications behave a bit strangely when modifier declarations and keysym declarations aren't consistent). Alternatively, you can use the lineswhich causes any key currently sending Caps Lock to be rebound to sending Compose instead. Either way, you need to arrange for the command
to be executed when your session starts. This is a common convention, but not all combinations of distribution/desktop environment do it automatically. If yours doesn't, add the command to the list of commands executed at the session start (in the XFCE4 configuration editor, go to “Session and Startup” → “Application Autostart” and add that command).
X11 (XKB)
XKB is neater and more powerful, but more cumbersome to use in general than xmodmap. There is a preset in the standard configuration to do what you want, so it's easy in your case: run the following command:
See the previous section for how to run this command when your session starts.
Linux console
Find out the keycode of the CapsLock key. Run
showkey
on a text console, press CapsLock, then wait 10 seconds forshowkey
to exit. On a PC, the keycode is 0x3a. You need to have the following line in your console keymap file:The default console keymap file is
/etc/console/boottime.kmap.gz
on Debian with theconsole-tools
package. It may be a different file under Mint; this is the file thatloadkeys
is invoked on in the boot scripts. If you prefer, you can leave the distribution-provided files intact, create a file with the line above, and runloadkeys /path/to/your/file.kmap
from/etc/rc.local
.