Difference between revisions of "Xmodmap"

From ArchWiki
Jump to: navigation, search
(Additional resources: Add post on Rolling Release)
m (Keymap table: typo)
Line 38: Line 38:
 
You can check which keymap corresponds to a key on your keyboard with xev (see: [[Extra Keyboard Keys#Using xev|Using xev]]).
 
You can check which keymap corresponds to a key on your keyboard with xev (see: [[Extra Keyboard Keys#Using xev|Using xev]]).
  
{{tip|There are predefined descriptive keycodes that make mapping additional keys easier (e.g. {{codeline|XF86AudioMute}}, {{codeline|XF86Mail}}). Those keycodes can be found in: {{filename|/usr/includ/X11/XF86keysym.h}}}}
+
{{tip|There are predefined descriptive keycodes that make mapping additional keys easier (e.g. {{codeline|XF86AudioMute}}, {{codeline|XF86Mail}}). Those keycodes can be found in: {{filename|/usr/include/X11/XF86keysym.h}}}}
  
 
== Custom table ==
 
== Custom table ==

Revision as of 23:12, 26 November 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 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.

Keymap table

Print the current keymap table formatted into expressions: Template:Command

Each keymap is followed by the keysyms it is mapped to. The above example indicates that the keycode Template:Codeline is mapped to the lowercase n keysym, while the uppercase N keysym is mapped to keycode 57 and shift.

Each keysym column in the table corresponds to a particular key combination:

  1. 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 to assign a later keysym without assigning earlier ones set the earlier keysyms to Template:Codeline.

You can check which keymap corresponds to a key on your keyboard with xev (see: Using xev).

Tip: There are predefined descriptive keycodes that make mapping additional keys easier (e.g. Template:Codeline, Template:Codeline). Those keycodes can be found in: Template:Filename

Custom table

You can create your own map and store it in your home directory (i.e. Template:Filename). Print the current keymap table into a configuration file:

xmodmap -pke > ~/.Xmodmap

Make the desired changes to Template:Filename and then test the new configuration with:

xmodmap ~/.Xmodmap

To activate your custom table when starting Xorg add the following: Template:File

Alternatively, edit the global startup script: Template:Filename.

Test changes

You can also make temporary changes for the current session. For example:

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 ;).

Reverse Scrolling

The natural scrolling feature available in OS X Lion can be mimicked with xmodmap. Since the synaptics driver uses the buttons 4/5/6/7 for up/down/left/right scrolling, you simply need to swap the order of how the buttons are declared in Template:Filename.

Open Template:Filename and append the following line to the file:

pointer = 1 2 3 5 4 7 6 8 9 10 11 12

Note how the 4 and 5 have been reversed.

Then update xmodmap:

# xmodmap ~/.Xmodmap

To return to regular scrolling simply reverse the order of the 4 and 5 or delete the line altogether. For more information check Peter Hutterer's post, Natural scrolling in the synaptics driver, or the Reverse scrolling direction ala Mac OS X Lion? forum thread.

Additional resources