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

, , …,

This page is tutorial on creating keyboard shortcuts, keymapping, keyboard layout.

In Linux, there are 2 steps to set keyboard shortcuts:

First, let's look at the easiest way.

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 window manager keys setup  2013-06-07
xfce window manager keys setup

The window manager typically lets you set keys related to manipulating windows, system-wide, such as switching windows, close window, max/min window, move window, show/hide/iconify window, switch workspace (aka virtual screen), etc.

xfce keyboard setting panel 2013-06-01
xfce keyboard setting panel

The keyboard setting tool typically lets you set a key to launch app, or run a shell script. But it does not lets you swap keys, or set a key to send keychord such as 【Ctrl+s

Swapping Keys, Remap Keys

xmodmap

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

See: Linux: xmodmap Tutorial ⌨

scancode, keycode, keysym

To work with keys in Linux, you must understand {scancode, keycode, keysym} because many key tools uses their concept and syntax.

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

xbindkeys

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

Linux: Xbindkeys Tutorial ⌨

Tool for Key Actions

「wmctrl」 for Switch Windows

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

See: Linux: 「wmctrl」 Add Keyboard Shortcuts to Switch to App ⌨

「xvkbd」 for Sending Keychords

xvkbd is a virtual keyboard for X window system. It is useful as a shell command to send keys.

see Linux: How to Set F2 F3 F4 to Cut Copy Paste Globally ⌨

Linux: Control Sound Level by Command Line

Linux: Control Sound Level with Command Line

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

「autokey」 for Expanding Abbreviations

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 used 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 https://wiki.archlinux.org/index.php/X_KeyBoard_extension

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.

Misc

dumpkeys -l

《udev rule to auto load keyboard layout when usb keyboard plugged in》@ http://superuser.com/questions/249064/udev-rule-to-auto-load-keyboard-layout-when-usb-keyboard-plugged-in

blog comments powered by Disqus