Fixing Xmonad Enter Bindings

So I switched over Xmonad during the Ubuntu-za jam with the help of Vaughan I say help but it was more like me copying his configurations over to my machine with very minor tweaking.

His configuration contains a few handy key bindings, one of which is super+shift+enter which opens up a terminal.  The problem was in the process of copying configs over this binding didn’t seem to work. We tried the standard things

  1. Absolute binary paths is /usr/bin/xterm
  2. Changing terminals to gnome-terminal
  3. Good old windows trick of rebooting
  4. xmonad –recompile

None of them seemed to work and we were out o luck so we just decided to remap it to super+shift+g (not 100% sure why G though).  This worked but it bugged me to no end. I eventually got some help in #xmonad on freenode  by vav.

Xev you can get what keycodes are emitted.

xev | grep keysym
state 0x0, keycode 36 (keysym 0xff0d, Return), same_screen YES,
state 0x0, keycode 36 (keysym 0xff0d, Return), same_screen YES,
state 0x0, keycode 77 (keysym 0xff7f, Num_Lock), same_screen YES,
state 0x10, keycode 77 (keysym 0xff7f, Num_Lock), same_screen YES,
state 0x10, keycode 104 (keysym 0xff8d, KP_Enter), same_screen YES,
state 0x10, keycode 104 (keysym 0xff8d, KP_Enter), same_screen YES

As you can see it see it seems to be when num-lock is on the keyevent fired for Enter key changes, I am not sure if this is a Xserver bug or not but other computers don’t seem to exhibit the same behavior?

Any how once you have that worked out fixing it is trivial just simply bind to both key events.

((modm .|.  shiftMask, xK_Return), spawn $ XMonad.terminal conf )
, ((modm .|.  shiftMask, xK_KP_Enter), spawn $ XMonad.terminal conf )

I hope that this might help some one Googling.

Thursday, April 1st, 2010 Ubuntu