MathCurvesSurfacesWallpaper GroupsGallerySoftwarePOV-Ray
ProgramingLinuxPerl PythonHTMLCSSJavaScriptPHPJavaEmacsUnicode ♥
Web Hosting by 1&1

Linux: Keyboard Layout, Keymapping, Keybinding, Tools ⌨

Xah Lee, , …,

This page is a collection of keyboarding tools for linux and a basic tutorial on how to use them.

If you are using a popular desktop such as Gnome, KDE, Ubuntu, Xfce, LXDE, your first stop is the Control Panel (aka Settings Manager, Preference Pane). There, usually there's apps named {keyboard, Window Manager}. You can change keys for many default actions there. Also, you can create new keys to run a terminal command.

For more advanced keyboarding, there are 2 steps to set keys in general:

Bind Key for Action

xbindkeys

«xbindkeys is a program that allows you to launch shell commands with your keyboard or your mouse under X Window. It links commands to keys or mouse buttons, using a configuration file. It's independant of the window manager and can capture all keyboard keys (ex: Power, Wake…).»

xbindkeys home page: http://www.nongnu.org/xbindkeys/xbindkeys.html

xbindkeys can bind almost any key or key combination. Example: Caps Lock, ScrLk, Pause, F2, number pad keys, multimedia keys, and special app launch buttons, and also standard modifier key combinations such as ▤ Menu, 【Ctrl+3】, 【Super+3】, etc.

Install: sudo apt-get install xbindkeys. There's also a GUI wrapper: sudo apt-get install xbindkeys-config

You must first create the config file yourself. Do:

xbindkeys -d > ~/.xbindkeysrc

The xbindkeys -d will print out a default config sample file.

Then, either manually modify the config file, when done, sent it a HUP signal to apply your change, like this killall -HUP xbindkeys.

Or, launch the GUI tool to set keys by xbindkeys-config &.

The hard part is the action part. You need to find write a shell command. Basically, call command that do what you want, ⁖ switch to a specific app, or press some other key such as 【Ctrl+w】 for close tab. The hard part is figuring out the syntax of this action command.

Command Line Tools to Manipulate Windows or Simulate Key Press

Tool to Switch Windows: wmctrl

wmctrl is a command line util to manipulate windows. ⁖ {switch, close, move, resize, set title, list, … }.

To install: sudo apt-get install wmctrl

Example use:

Tool to Type Other Keys: xdotool

xdotool. «programatically simulate keyboard input and mouse activity. It does this using X11's XTEST extension and other Xlib functions.»

xdotool home page: http://www.semicomplete.com/projects/xdotool/

Install: sudo apt-get install xdotool

Tool to Expand Abbreviations: AutoKey

AutoKey. For expanding abbrev to full words/text.

Install: sudo apt-get install autokey-gtk (for Gnome) or sudo apt-get install autokey-qt (for KDE)

Keyboard Layout Tools

• A Dvorak key layout with QWERTY layout for key shortcuts. https://code.google.com/p/dvorak-qwerty/

Swap Control and Alt via xmodmap

create a file at 〔~/.Xmodmap〕. The file content should be this:

! -*- coding: utf-8 -*-
! 2013-02-04

! swap Ctrl and Alt keys

! here's the default setting on special keys
!  xmodmap -pke | egrep '(Control|Super|Alt|Menu)'

! keycode  37 = Control_L NoSymbol Control_L
! keycode  64 = Alt_L Meta_L Alt_L Meta_L
! keycode 105 = Control_R NoSymbol Control_R
! keycode 108 = Alt_R Meta_R Alt_R Meta_R
! keycode 133 = Super_L NoSymbol Super_L
! keycode 134 = Super_R NoSymbol Super_R
! keycode 135 = Menu NoSymbol Menu
! keycode 147 = XF86MenuKB NoSymbol XF86MenuKB
! keycode 204 = NoSymbol Alt_L NoSymbol Alt_L
! keycode 206 = NoSymbol Super_L NoSymbol Super_L

clear control
clear mod1
keycode 37 = Alt_L Meta_L
keycode 105 = Alt_R Meta_R
keycode 64 = Control_L
keycode 108 = Control_R
add control = Control_L Control_R
add mod1 = Alt_L Meta_L

then, logout then login.

Misc

• Keycodes are described in 〔/usr/include/X11/XF86keysym.h〕.

thanks to {Ci, meowcat}.

Here's more articles and tools from Dotan Cohen:

// Making new layouts

http://www.x.org/wiki/XKB

http://wiki.linuxquestions.org/wiki/Altering_or_Creating_Keyboard_Maps
http://www.freedesktop.org/wiki/Software/XKeyboardConfig
http://wiki.linuxquestions.org/wiki/Configuring_keyboards
http://wiki.linuxquestions.org/wiki/Background:_How_keyboards_work

// Enabling multimedia keys (also useful for the former)
http://en.gentoo-wiki.com/wiki/Microsoft_Natural_Ergonomic_Keyboard_4000
https://wiki.kubuntu.org/KDEMultimediaKeys
http://cweiske.de/howto/xmodmap/allinone.html
http://linux.die.net/man/8/setkeycodes
http://rick.vanrein.org/linux/funkey/
http://juliano.info/en/Blog:Memory_Leak/Linux,_KDE:_Mapping_functions_to_extra_keys
http://linux.playofmind.net/extra_keys/
http://dev-loki.blogspot.com/2006/04/mapping-unsupported-keys-with-xmodmap.html
blog comments powered by Disqus