Sunday, July 27, 2008

XFCE 4.4 "Special Key" Bindings

The concept of key binding in XWindow has always been vague to me until I fix the key binding in my window manager. I'll explain how it works with an example. So, I have this problem of using the "windows" key to open the main menu in XFCE 4.4 in my Slamd64 12.1. This key is called Xfce-popup-menu in Xfce keyboard setting. The key is not detected by Xfce, the Window Manager. Here's how I got it working.

  1. Find the keycode of the problematic key. I use xev to find the keycode. Run xev from an X terminal and set the focus to xev window and watch for the keycode in the terminal from which you launch xev. I found that the "windows" keykode is 115


  2. Edit/create .Xmodmap file in your home directory and "bind" the keycode 115 into one of the key symbol recognized by the window manager. /usr/share/X11/XKeysymDB contains the list of key symbols for X11. My .Xmodmap reads like this:

    keycode 115 = XF86MenuKB
    keycode 162 = XF86AudioPlay
    keycode 164 = XF86AudioStop
    keycode 160 = XF86AudioMute
    keycode 174 = XF86AudioLowerVolume
    keycode 176 = XF86AudioRaiseVolume
    keycode 178 = XF86WWW



  3. Run xmodmap .Xmodmap to activate the keycode-to-key-symbol binding.

  4. Then map the key symbol to the window manager keyboard setting. In XFCE 4.4 open Settings|Keyboard Settings menu then select the shortcut tab and then create new theme then select add. In the dialog that's shown, enter the command that you would like to execute when the key is pressed. In my case I enter: Xfce-popup-menu and in the subsequent dialog I press the "windows" key to assign the binding in XFCE. This will bind the X86MenuKB key symbol to Xfce-popup-menu command.




Links:

http://wiki.xfce.org/faq
http://gentoo-wiki.com/HOWTO_Use_Multimedia_Keys#Setting_up_xmodmap
Post a Comment

No comments: