Super User is a question and answer site for computer enthusiasts and power users. 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'm using an Apple keyboard which has some annoyances compared to other keyboards. Namely, the Alt_L and Super_L keys are swapped, and the bar and less keys are swapped ("|" and "<").

I've written an Xmodmap file to swap the keys back:

keycode  49 = less greater less greater onehalf threequarters
keycode  64 = Super_L NoSymbol Super_L
keycode  94 = bar section bar section brokenbar paragraph
keycode 108 = Super_R NoSymbol Super_R
keycode 133 = Alt_L Meta_L Alt_L Meta_L
keycode 134 = Alt_R Meta_R Alt_R Meta_R

I did this by identifying the keys using xev and the default modmap xmodmap -pke and swapping the keycodes. xev now identifies all my keys as correct, which is awesome! I can also use the correct keys to type the bar and less than symbols. (I followed this answer on askubuntu: http://askubuntu.com/q/24916/52719)

But it seems the change isn't very deep. For instance, the Super key is now broken in the Compiz Settings Manager. No shortcuts involving the Super key works (but the Alt key does). Also the settings dialog for Gnome Do doesn't heed the changes in xmodmap, and I can't open the Gnome Do window anymore if I use any of the remapped keys.

So to summarize, everything broke.

I would like a deeper way of telling Ubuntu (or any other Linux distro for that matter) which keys are which on the keyboard. Is there a way to edit the Keyboard Layout directly? I'm using the Norwegian Bokmål keyboard layout. Does it reside in a file somewhere I could edit?

Any comments, previous experiences or relevant stray thoughts would be greatly appreciated -

Thanks

share|improve this question
    
possible duplicate of Remap Keys in Linux – Ƭᴇcʜιᴇ007 Apr 8 '12 at 18:45
    
Not a duplicate. The answer of that question is unacceptable – Hubro Apr 8 '12 at 20:15
    
The accepted answer is not what determines a duplicate question. If it is the same question, then please look into setting a bounty on that question to get more/better answers. If you feel it's not the same Question, please edit yours to explain why it's different (referencing the other). – Ƭᴇcʜιᴇ007 Apr 8 '12 at 20:19
up vote 1 down vote accepted

I finally got this working after hours of trying. I found the file where the evdev scancodes are translated into xfree86 keycodes under X11, namely /usr/share/X11/xkb/keycodes/evdev. I opened that file as root and moved the key codes around using the default xmodmap settings as a reference (xmodmap -pke). My final edits were quite simple:

<LSGT> = 49; // This was 94
<TLDE> = 94; // This was 49
<LWIN> = 64; // This was 133
<LALT> = 133; // This was 64
<RWIN> = 108; // This was 134
<RALT> = 134; // This was 108
share|improve this answer

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .