Make Debian default to caps lock as control system-wide by editing `/etc/default/keyboard`:
XKBOPTIONS="ctrl:nocaps"
See SETXKBMAP(1) and XKEYBOARD-CONFIG(7).
Show the current config with setxkbmap -query
or setxkbmap -print -verbose 10
.
Look at the available options in /usr/share/X11/xkb/rules/evdev.lst
. Here are some I find useful:
ctrl:nocaps Caps Lock as Ctrl ctrl:lctrl_meta Left Ctrl as Meta shift:both_capslock Both Shift keys together toggle Caps Lock
or
caps:hyper Caps Lock as Hyper_L
or
altwin:swap_alt_win Alt is swapped with Win
Invoke options like:
setxkbmap -model pc105 -layout us -option \ -option ctrl:nocaps -option ctrl:lctrl_meta -option shift:both_capslock
(The empty -option
argument resets things, so we start from a clean slate.)
There are some things setxkbmap
can't do with simple options. For those things, create ~/.xkb/symbols/mysymbols
and ~/.xkb/keymap/mykeymap
.
Apply the custom keymap with: xkbcomp -I$HOME/.xkb ~/.xkb/keymap/mykeymap $DISPLAY.
Also see the man pages for xkeyboard-config
and setxkbmap
and keyboard
.
N.B. I've found xkb to be a little flaky. For example, if I set keyboard options in my .xsession with xsetkbmap, those options get reset to defaults in the keyboard is unplugged/plugged. As an alternative, system-wide defaults can be set in /etc/defaults/keyboard
.
xmodmap
maps the KeyCodes of physical keys on your keyboard to what KeySym value get sent when you press that key.
Determine what key is what by running xev
from a terminal. It will show you the keycode for any key you press. xmodmap -pk
may also be useful; it prints the current key mappings. (Using xmodmap -pke
gives the same information as a list of commands that can be fed back to xmodmap
like xmodmap -e 'keycode 47 = semicolon colon semicolon colon'
.)
Print the keycodes and keysym values for modifier keys like Caps Lock, Alt, and Control with xmodmap -pm
. Changing modifier keys is slightly different from changing other keys, using clear, remove, and add.
Once you know what you want to do with xmodmap
, either save your xmodmap
commands to the beginning of your .xsession
file if you only have one or two changes, or keep your entire key mapping in its own file by adding this to your.xsession
:
if [ -s ~/.Xmodmap ]; then xmodmap ~/.Xmodmap fi
...and having xmodmap
create a .Xmodmap
file b:verbose set buftypeased on your current settings:
xmodmap -pke > ~/.Xmodmap
© Paul Gorman