Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I haven't found the correct keyboard layout for my macbook pro yet. I've found one that looks like it though (in .xinitrc):

setxkbmap -layout us -variant mac

yet this has one difference: the (',~) key and the (§,±) keys are switched. I've always managed this by editing the corresponding file in §/etc/share/X11/xkbbut it is a drag to have to do this everytimX11` updgrades.

Can it be done from a local file e.g. .xinitrc?

share|improve this question
up vote 2 down vote accepted

The file you want is .xmodmap Have a look at man xmodmap for details on how to set it up.

xmodmap uses the physical keycodes to make the change. You can get those from xev. Launch it, then tap the appropriate keys and see what keycode number pops up.

You should only need two lines in your .xmodmap, both of them looking something like

keycode 49 = grave asciicircum
keycode 15 = <whichever keys are activated in first-level> section plusminus

Those two keycodes, by the way, are wild guesses and probably wrong.

share|improve this answer

Your Answer


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.