File:  [NetBSD Developer Wiki] / wikisrc / tutorials / how_to_customize_keyboard_mappings_in_x.mdwn
Revision 1.2: download - view: text, annotated - select for diffs
Sun Feb 5 07:14:36 2012 UTC (3 years ago) by schmonz
Branches: MAIN
CVS tags: HEAD

How to readjust your keyboard map to your liking. 



#  Introduction 

Sometimes, esp. when working in an X environment, the default keyboard layouts aren't enough... 

#  xbindkeys 

  * Program that allows you to launch shell commands with your keyboard or mouse under X. It links commands to keys or mouse buttons. 
      cd /usr/pkgsrc/x11/xbindkeys
      make install clean

Create a default file 
      xbindkeys --defaults > $HOME/.xbindkeysrc

Grab a key code 
      xbindkeys -k

      xbindkeys -mk

for multi-keys respectively. 

##  Examples 

  * .xbindkeysrc 
      # control+shift+d starts an xterm (it's a comment)
        control+shift + q
      # Menu key starts xbindkeys_show
      # Control + mouse button 1 starts an xterm
        Control + b:1
      # Control+Shift+a  release event starts rxvt
        release+control+shift + a
      # Control + mouse button 2 release event starts rxvt
        Control + b:2 + Release

#  xmodmap 

  * X utility for modifying keymaps and pointer button mappings. Call it from .xinitrc or .xsession, depending on whether you use 'startx' or the X display manager, like: 
       xmodmap ~/.xmodmaprc

##  German umlauts with en_US keyboards 

  * I use the [right-Alt]+[vowel] key combination. For that, add the following to your .xmodmaprc 
       ! Alt_R + aAeEoOuUs für Umlaute auf US-Tastaturen.
       clear mod1             
       add mod1 = Alt_L             
       add mod3 = Alt_R                
       keysym Alt_R = Mode_switch               
       keysym  u    = u U udiaeresis      Udiaeresis              
       keysym  a    = a A adiaeresis      Adiaeresis              
       keysym  o    = o O odiaeresis      Odiaeresis                
       keysym  s    = s S ssharp            

##  Swap Caps_Lock and Control_L 

  * This comes in handy esp. when using Emacs, screen and similar programs. 
      ! Swap Caps_Lock and Control_L
      remove Lock = Caps_Lock
      remove Control = Control_L
      keysym Control_L = Caps_Lock
      keysym Caps_Lock = Control_L
      add Lock = Caps_Lock
      add Control = Control_L

Alternatively you can add in the InputDevice section of your keyboard in /etc/X11/xorg.conf (dunno if Xfree.conf works): 
      Option  "XkbOptions"    "ctrl:swapcaps"

##  Mouse emulation mode with Num_Lock 
      remove Lock = Num_Lock
      add Lock = Control+Mod2 + Num_Lock

CVSweb for NetBSD wikisrc <> software: FreeBSD-CVSweb