XmodMap

Differences between revisions 2 and 4 (spanning 2 versions)
Revision 2 as of 2006-03-09 01:53:55
Size: 4013
Editor: 205
Comment: v.1.1 - Changed formatting
Revision 4 as of 2006-03-09 03:10:42
Size: 4155
Editor: 205
Comment: english v.1.3 - moved pt-br version to a new page
Deletions are marked like this. Additions are marked like this.
Line 1: Line 1:
Depois de me debater um pouco (bastante) pra conseguir fazer funcionar as teclas '''''Win''''' do teclado com o Compiz, acabei aprendendo como funciona o formato do tal do '''xmodmap'''. = Xmodmap & Compiz =
Line 3: Line 3:
Segue aqui uma breve explicação e exemplo de como editar o arquivo __xmodmap.seuteclado__ para habilitar as teclas '''''Win''''' como ''Super'': 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'':
Line 7: Line 9:
Inicialmente, você deve descobrir qual o código da tecla você quer alterar, chamado ''keycode''. Para isso, um programa muito útil é o '''xev'''. Execute-o em um terminal e uma pequena janela aparecerá. No terminal, diversas informações serão mostradas quando você pressiona alguma tecla. Tente pressionar a tecla '''''Win''''' da esquerda, o resultado será parecido com isso: 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:
Line 15: Line 17:
Note que o keycode é o número '''115'''. Para a tecla '''''Win''''' da direita, o keycode se '''116'''. Notice that the keycode value is '''115'''. For the '''''Right Win''''' key, the keycode will be '''116'''.
Line 18: Line 20:
Munidos desta informação, podemos agora editar o arquivo xmodmap correspondente ao nosso teclado. Os layouts disponíveis no Ubuntu estão localizados na pasta __/usr/share/xmodmap__.
Exemplo: {{{bash:~$ sudo gedit /usr/share/xmodmap/xmodmap.br}}}
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:~$ sudo gedit /usr/share/xmodmap/xmodmap.us-101}}}
Line 21: Line 23:
Dando uma olhada no arquivo, percebemos logo que ele serve para ligar um keycode de uma tecla com o que realmente aquela tecla deve fazer no sistema.
Queremos alterar a função das teclas '''''Win''''', cujo keycode, como sabemos agora, é 115 e 116, então vamos para as linhas correspondentes. Exemplo:
{{{keycode 115 = Select
keycode 116 = Mode_switch}}}
Line 26: Line 24:
Queremos que elas sejam interpretadas como teclas ''Super'', então editamos para ficar assim: A quick look on the file and we soon realize that it's 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:
Line 30: Line 33:
Ou seja, ''Super_L'' corresponde à tecla Super esquerda e ''Super_R'' à tecla Super da direita (L de Left e R de Right, claro).
Line 32: Line 34:
Mas espere, ainda não terminamos, e é aqui que muitos (leia-se __EU__) se confundem. A função ''Super'' é uma função especial, chamada ''modificadora'', e é preciso avisar que iremos usá-la.
Para isso, o xmodmap nos dá suporte para oito modificadores, sendo eles:
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:
Line 38: Line 40:
Deles, cinco são de livre uso, adivinhe quais! heh Five of them are of free use. Guess which ones :P
Line 41: Line 43:
Okay, então, como avisamos ao xmodmap que estamos usando as teclas Super? Simples! :
 1. Primeiro, vemos quais modificadores já estão sendo usados. Exemplo: {{{add Mod1 = Alt_L
add Mod2 = Mode_switch}}}. Vamos usar um novo modificador livre, neste caso Mod3.
 2. Inicializamos o novo modificador no início do arquivo: {{{clear Mod1
clear Mod2
clear Mod3}}}
 3. E no final do arquivo especificamos que estamos usando as teclas Super: {{{add Mod3 = Super_L Super_R}}}
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
}}}
Line 49: Line 59:
Muito bem, serviço feito, agora salvamos o arquivo e dizemos para o xmodmap carregar nossas novas configurações. No terminal, digitamos:
Very well, task accomplished, now we save the file and tell xmodmap to load our new configurations. At the terminal, we type:
Line 52: Line 63:
Para verificar o resultado da nossa modificação, execute: {{{bash:~$ xmodmap}}} sem argumentos. Deve mostrar algo assim: To verify the result of our modification, run: {{{bash:~$ xmodmap}}} with no extra arguments. It should show something like this::
Line 56: Line 67:
mod1 Alt_L (0x40), Meta_L (0x9c)
mod2 Mode_switch (0x71)
mod1 Alt_L (0x40), Alt_R (0x71)
mod2 Num_Lock (0x4d)
Line 62: Line 73:
Experimente usar os atalhos do Compiz definidos com a tag <Super> agora! Try using the Compiz commands defined with the <Super> tag now!
Line 64: Line 75:
Para que suas alterações sejam usadas sempre, coloque um script pra carregar seu xmodmap toda vez que iniciar uma sessão no Gnome (pode ser no mesmo script que carrega o Compiz, como mostrado nos tutoriais sobre o assunto). 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).
Line 66: Line 77:
For more information about other usable modifiers, check:[[BR]]
http://www.in-ulm.de/~mascheck/X11/xmodmap.html - Bastante informativo[[BR]]
http://paste.lisp.org/display/1995 - Exemplos interessantes[[BR]]
Line 67: Line 81:
Para mais informações, visite:[[BR]]
http://www.in-ulm.de/~mascheck/X11/xmodmap.html - Bastante informativo[[BR]]
http://paste.lisp.org/display/1995 - Exemplos interessantes
~-v.1.3-~

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:~$ sudo gedit /usr/share/xmodmap/xmodmap.us-101

A quick look on the file and we soon realize that it's 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:

Shift

Control

Lock

Mod1

Mod2

Mod3

Mod4

Mod5

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.

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

  1. 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) mod4 mod5}}}

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:BR http://www.in-ulm.de/~mascheck/X11/xmodmap.html - Bastante informativoBR http://paste.lisp.org/display/1995 - Exemplos interessantesBR

v.1.3

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