versão em português Lkraider/XmodMap-pt-BR

Xmodmap & Compiz

After getting seriously beaten by xmodmap at trying to make the Win keys work with Compiz, I finally decided I had to actually learn to use it properly.

Threehundred google searches later, here I am to share my fresh new knowlodge and experiences on how to edit the xmodmap.yourkeyboard to enable the Win keys to act as Super:

First things first, you have to find out what is the keycode to the key you want to configure. For that you can use the xev program. Run it on a terminal and a small window will popup, while the terminal will display several informations about the keys you press. Try pressing the Left Win key, the result should look similar to this:

KeyPress event, serial 30, synthetic NO, window 0x2e00001,
    root 0x52, subw 0x0, time 3698176719, (596,523), root:(610,593),
    state 0x0, keycode 115 (keysym 0xffeb, Super_L), same_screen YES,
    XLookupString gives 0 bytes:
    XmbLookupString gives 0 bytes:
    XFilterEvent returns: False

Notice that the keycode value is 115. For the Right Win key, the keycode will be 116.

With that information in hands, we can now edit the xmodmap file that corresponds to our keyboard layout. The layouts avaiable in Ubuntu are located in the /usr/share/xmodmap folder. Example: bash:~$ gksudo gedit /usr/share/xmodmap/xmodmap.us-101

A quick look on the file and we soon realize that its purpose is to connect a keycode value to an actual key function (like writting a specific symbol). We want to configure the Win keys, which, as we now know, have the keycodes 115 and 116, so we locate the corresponding lines. Example:

keycode 115 = Meta_L
keycode 116 = Meta_R

What we want is that they be interpreted as Super keys, so we edit as follows:

keycode 115 = Super_L
keycode 116 = Super_R

But wait, we are not quite ready yet, because it is here that many people (ie: ME) get confused! The Super function is actually a special function, which is called a modifier, and we need to let xmodmap know we are going to use it as so. For that, xmodmap gives us eight modifiers, which are:









Five of them are of free use. Guess which ones :P

Okay, so, how do we tell xmodmap we are using the Super modifiers? Simple! :

  1. First, we check which modifiers are already in use. Example:

    add     shift   = Shift_L Shift_R
    add     lock    = Caps_Lock
    add     control = Control_L Control_R
    add     mod1    = Alt_L Alt_R
    add     mod2    = Num_Lock

    We are going to use a free modifier, in this case mod3. The number is not important, just pick a free one.

  2. Now we inicialize the new modifier at the beggining of the file, if it isn't already:

    clear shift
    clear lock
    clear control
    clear mod1
    clear mod2
    clear mod3
  3. And finally, at the end of the keycode list we specify we are using the Super modifiers:

    add mod3 = Super_L Super_R

Very well, task accomplished, now we save the file and tell xmodmap to load our new configurations. At the terminal, we type: bash:~$ xmodmap /usr/share/xmodmap/xmodmap.br

To verify the result of our modification, run: bash:~$ xmodmap with no extra arguments. It should show something like this::

shift       Shift_L (0x32),  Shift_R (0x3e)
lock        Caps_Lock (0x42)
control     Control_L (0x25),  Control_R (0x6d)
mod1        Alt_L (0x40),  Alt_R (0x71)
mod2        Num_Lock (0x4d)
mod3        Super_L (0x73) Super_R (0x74)

Try using the Compiz commands defined with the <Super> tag now!

For the changes to take effect everytime, make a script to load your xmodmap at the Gnome session startup (you can use the same script that is loading Compiz, as shown on other tutorials about this).

For more information about other usable modifiers, check:


Lkraider/XmodMap (last edited 2008-08-06 17:00:03 by localhost)