Linux: Keyboard Tools for Key Layout, Keymapping, Keybinding ⌨

, , …,

This page is a list of Linux keyboard tools and tutorial.

Basic of Keybinding Using Control Panel

The easiest way to add a new keyboard shortcut or keyboard layout, is the system control panel in a graphical user interface (available in any of the Gnome, KDE, Ubuntu, Xfce, LXDE). Under the system control panel (aka Setting Manager), usually there's apps named Window Manager, or Keyboard, or Keyboard Layout.

xfce keyboard setting panel 2013-06-01
xfce keyboard setting panel
xfce window manager keys setup  2013-06-07
xfce window manager keys setup

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

Swapping Keys, Remap Keys


xmodmap is a simple tool that lets you remap/swap keys for apps running under X11.

See: Linux: xmodmap Tutorial ⌨

scancode, keycode, keysym

How find the scancode of a key?

See: Linux: How to Find Keyboard Scancode of a Key? ⌨

How to find the keycode & keysym of a key?

Type xev, then press a key. See: Linux: Show X11 Keycode & Keysym ⌨

How to set system keyboard layout?

See: Linux: Set System Keyboard Layout ⌨

Tool to Bind Key


if your desktop doesn't provide a way to bind a key to launch a script, then you can use xbindkeys.

xbindkeys home page:

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

Tool for Key Actions

Command 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:

Use xprop util to find the name of a app's window class name. 〔➤ Linux: Commands Related to GUI Apps〕)

here's some popular app's window class name:

Global Set Copy Paste to F3 F4, Using xvkbd

xvkbd is a virtual keyboard for X window system

Here's how to set {F2, F3, F4} keys to do {cut, copy, paste}, globally.

Install xvkbd sudo apt-get install xvkbd, and also install sudo apt-get install xbindkeys, then, add these lines into ~/.xbindkeysrc:

"xvkbd -no-jump-pointer -xsendevent -text "\Cx" 2>/dev/null"
    m:0x0 + c:68

"xvkbd -no-jump-pointer -xsendevent -text "\Cc" 2>/dev/null"
    m:0x0 + c:69

"xvkbd -no-jump-pointer -xsendevent -text "\Cv" 2>/dev/null"
    m:0x0 + c:70

(thanks to XueFuqiao)

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.»

(note: i tried xdotool under Ubuntu/xfce. Doesn't work in my first 30 min of looking into it.)

Install: sudo apt-get install xdotool

Example. Send 【Ctrl+w】 to close tab. xdotool key --delay 40 Control_L+w

Example. Click on upper left corner, (90, 10) pixels. xdotool mousemove 90 10 click 1

(note: i haven't tried using 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)

(note: i haven't tried using AutoKey)

Other Keyboard Tools

xkb: X Keyboard Extension

xkb (X Keyboard Extension) is a more capable system to set keys in X11, than xmodmap.

setxkbmap → set the keyboard using the X Keyboard Extension.

# set layout to us
setxkbmap -layout us
# set layout to US dvorak
setxkbmap -layout us -variant dvorak
# setxkbmap example, set to US, Dvorak, and swap Ctrl Caps
setxkbmap -layout us -variant dvorak -option ctrl:swapcaps
# reset all custom keymap to default
setxkbmap -option

xkb tutorial

Mouse Extra Button Tools

How to set 5 buttons mouse?

apt-get install imwheel for config mouse buttons.

Bind Keys in Emacs

See: Emacs Keybinding, Keyboard, Articles Index.

Linux: Control Sound Level with Command Line

Linux: Control Sound Level with Command Line


dumpkeys -l

《udev rule to auto load keyboard layout when usb keyboard plugged in》@

blog comments powered by Disqus