Difference between revisions of "Xmodmap"

From ArchWiki
Jump to: navigation, search
(LINKS)
(Add article summary template)
Line 3: Line 3:
 
{{i18n|Xmodmap}}
 
{{i18n|Xmodmap}}
 
[[fr:Xmodmap]]
 
[[fr:Xmodmap]]
 +
 +
{{Article summary start}}
 +
{{Article summary text|A general overview of modifying keymaps and pointer mappings with xmodmap.}}
 +
{{Article summary heading|Related}}
 +
{{Article summary wiki|Xorg}}
 +
{{Article summary wiki|Extra Keyboard Keys in Xorg}}
 +
{{Article summary end}}
  
 
'''Xmodmap''' is a utility for modifying keymaps and pointer button mappings in [[Xorg]].
 
'''Xmodmap''' is a utility for modifying keymaps and pointer button mappings in [[Xorg]].

Revision as of 22:14, 11 September 2011

This template has only maintenance purposes. For linking to local translations please use interlanguage links, see Help:i18n#Interlanguage links.


Local languages: Català – Dansk – English – Español – Esperanto – Hrvatski – Indonesia – Italiano – Lietuviškai – Magyar – Nederlands – Norsk Bokmål – Polski – Português – Slovenský – Česky – Ελληνικά – Български – Русский – Српски – Українська – עברית – العربية – ไทย – 日本語 – 正體中文 – 简体中文 – 한국어


External languages (all articles in these languages should be moved to the external wiki): Deutsch – Français – Română – Suomi – Svenska – Tiếng Việt – Türkçe – فارسی

Template:Article summary start

Template:Article summary text Template:Article summary heading Template:Article summary wiki Template:Article summary wiki Template:Article summary end

Xmodmap is a utility for modifying keymaps and pointer button mappings in Xorg.

Introduction

The Linux kernel generates a code each time a key is pressed on a keyboard. That code is compared to a table of keycodes defining a figure that is then displayed.

This process is complicated by Xorg, which starts its own table of keycodes. Each keycode can belong to a keysym. A keysym is like a function, started by typing a key. Xmodmap allows you to edit these keycode-keysym relations.

Structure

keycode n = keysym1 keysym2 keysym3 keysym4 keysym5 keysym6

n is representing a number. The keysymX stands for:

1  only the key
2  shift + key
3  mode_switch + key
4  mode_switch + shift + key
5  AltGr + key
6  AltGr + shift + key

Not all keysyms have to be set. But if you want e.g. keysym5, you have to set keysym1 till keysym5. Therefore, you can use NoSymbol which is doing nothing.

Comments start with a !

Editing

Extract your actual table of keycodes in a file (here: .xmod)

xmodmap -pke > ~/.xmod

Now you can edit .xmod. The new .xmod get loaded by

xmodmap ~/.xmod

This has be done after each start of X! So put it in your autostart...

You can get the keycode (and more information) of a key with xev (or xkeycaps). If you start xev within a shell, a window will be opened and if you type a key, there will be some informations about it in the shell. Among others you get the keycode.

Example

If I'ld to get an 'e' if I type 'l' and an 'E' if I type 'L', I'ld have to change

keycode  46 = l L l L lstroke Lstroke lstroke

to

keycode  46 = e E l L lstroke Lstroke lstroke

(Maybe my standard keycode differs from yours. This will be an result of using different keyboard layouts)

Keysym

It is also possible, to change the keysym. I.e:

keysym a = e E
  • a -> e
  • shift+a -> E

It has the same effect as editting the corresponding keycode.

xmodmap within a shell

Within a shell, you can type make changes for this session. It's useful for testing. Examples:

xmodmap -e "keycode  46 = l L l L lstroke Lstroke lstroke"
xmodmap -e "keysym a = e E"

Special keys/signals

You can also also edit the keys: shift, ctrl alt and super (there always exists a left and a right one (Alt_R=AltGr))

At first you have to delete/clear the signals that should be edited. Write at the beginning of your Xmodmap file (here: ~/.xmod) :

!clear Shift
!clear Lock
clear Control
!clear Mod1
!clear Mod2
!clear Mod3
clear Mod4
!clear Mod5
keycode   8 =
...

Remember: ! is a comment. So only Control and Mod4 (Standard: Super_L Super_R) get cleared.

Write the new signals at the end of ~/.xmod:

keycode 255 =
!add Shift   = Shift_L Shift_R
!add Lock    = Caps_Lock
add Control = Super_L Super_R
!add Mod1    = Alt_L Alt_R
!add Mod2    = Mode_switch
!add Mod3    =
add Mod4    = Control_L Control_R
!add Mod5    =

Here: We exchanged the Super-keys with the ctrl-keys. My lil' finger likes that really ;).

Additional resources