Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

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: How do I remap certain keys?)

But it seems the change isn't very deep. Here are some examples

  • The Super key is now broken in the Compiz Settings Manager. No shortcuts involving the Super key works (but the Alt key does).
  • 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.
  • Chrome shortcuts doesn't care about the xmodman changes, I now have to use Super+D to focus the address field (Should be Alt+D)

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
add comment

1 Answer 1

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
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.