xmonad and remapping keys with xmodmap

I've recenly bought a new notebook that comes with a numeric keypad. I don't like numeric keypads, so I remapped the keys to generate the regular key codes for arrow keys, home, end, pgup and pgdown, etc xmodmap -e "keycode 83 = Left Left" ... In my xmonad.hs I use alt-shift-<arrows> for shrinking and expanding windows: ((modMask .|. shiftMask, xK_Left ), sendMessage Shrink) ... but when remapping strange things happen: - using the default keyboard layout, the normal arrow keys work with xmonad, but the numpad arrows do not ('KP_Left' is sent instead of 'Left', so that is to be expected) - I remap the numpad arrows to send 'Left' instead of KP_Left': xmodmap -e "keycode 83 = Left Left" ... - Xmonad now works with the keypad left arrow key, but the normal arrow key (that was not remapped) is no longer picked up by xmonad. It works for all other apps I tested, though. xev shows the normal key symbols when pressing the keys. Any advice on how to debug of fix this is much appreciated, Ico -- :wq ^X^Cy^K^X^C^C^C^C

Quoting Ico
- I remap the numpad arrows to send 'Left' instead of KP_Left':
xmodmap -e "keycode 83 = Left Left" ...
- Xmonad now works with the keypad left arrow key, but the normal arrow key (that was not remapped) is no longer picked up by xmonad. It works for all other apps I tested, though. xev shows the normal key symbols when pressing the keys.
Yeah, that's a bit annoying. The culprit is that xmonad asks X to convert keysyms into keycodes, then binds keycodes instead of keysyms. This is subtly a bug because many keycodes may map to the same keysym, in which case X will choose one arbitrarily to return from the conversion. You might be interested in http://code.google.com/p/xmonad/issues/detail?id=273 which even has a patch you might want to try applying to xmonad core. Spencer is skeptical about the patch, but it looks like just what the doctor ordered to me. ~d

* On Fri Jan 18 15:45:26 +0100 2013, wagnerdm wrote:
Quoting Ico
: - I remap the numpad arrows to send 'Left' instead of KP_Left':
xmodmap -e "keycode 83 = Left Left" ...
- Xmonad now works with the keypad left arrow key, but the normal arrow key (that was not remapped) is no longer picked up by xmonad. It works for all other apps I tested, though. xev shows the normal key symbols when pressing the keys.
Yeah, that's a bit annoying. The culprit is that xmonad asks X to convert keysyms into keycodes, then binds keycodes instead of keysyms.
Yes, that makes perfect sense.
This is subtly a bug because many keycodes may map to the same keysym, in which case X will choose one arbitrarily to return from the conversion.
That's a bit of a funny way of doing things, but explains just fine what I'm seeing here.
You might be interested in
Thank you, I'll check that out. Ico -- :wq ^X^Cy^K^X^C^C^C^C

* On Fri Jan 18 15:45:26 +0100 2013, wagnerdm wrote:
Yeah, that's a bit annoying. The culprit is that xmonad asks X to convert keysyms into keycodes, then binds keycodes instead of keysyms. This is subtly a bug because many keycodes may map to the same keysym, in which case X will choose one arbitrarily to return from the conversion. You might be interested in
I applied that patch to xmonad 0.10, but unfortunately ghc does not like the result: XMonad/Main.hsc:355:40: Couldn't match expected type `KeyCode' with actual type `Char' In the second argument of `keycodeToKeysym', namely `code' In the second argument of `($)', namely `keycodeToKeysym dpy code 0' In a stmt of a 'do' block: io $ keycodeToKeysym dpy code 0 My haskell-fu happens to be a bit bit low today (e.g. I have absolutely *no clue* on how to fix this), is there a simple fix to help me out here? Ico -- :wq ^X^Cy^K^X^C^C^C^C
participants (3)
-
Ico
-
Ico Doornekamp
-
wagnerdm@seas.upenn.edu