An Attempt to Apply Emacs-Keybindings Globally on Linux/X11

[ 日本語 | English ]


A small tool that applies Emacs-keybindings on all Linux/X11 applications is provided here. By using this, you can use any applications (e.g., LibreOffice, okular (PDF viewer), and etc.) with Emacs-like keybindings running on Linux

This tool is implemented as a proof-of-concept of an alternative of XKeymacs or emacs.ahk, which are implemented on Win32 and thus lacked on Linux/X11. It is made up of about 1,000 lines of code, and thus relatively easy to hack. (I personally hope that someone builds a more practical and generalized keybinding configuration tool using similar techniques :-)

Running Platform
OpenSUSE 11.4/12.1 + KDE4 (Some modifications might be needed on other Linux distributions/window managers)
x11keymacs.tar.gz (9KB)
MIT License


Simple do "make & make install", and the executable file (x11keymacs) will be installed under /usr/local/bin

$ cd x11keymacs/
$ make
$ sudo make install

Usage (General Information)

In order to run x11keymacs, you need the following previleges:

By running the following command from the user having the above privileges, keyboard input is converted to Windows-like input from the original Emacs-like keybindings.
(Note that you need to modify the /dev/input/... part to match your keyboard model.)

$ /usr/local/bin/x11keymacs /dev/input/by-id/usb-PFU_Limited_HHKB_Professional_JP-event-kbd &

For instance, Ctrl-P key input is converted to up key, which helps Emacs-users to avoid being frustrated under some "Print" dialog box that has mistakenly popped up.

X11keymacs accepts --exclude filename option for excluding window titles from applying keyboard input conversion using regular expressions. For example, by adding --exclude $HOME/.x11keymacs_exclude to the parameter and by providing the "$HOME/.x11keymacs_exclude" of the following content would exclude Emacs(Gtk+) and VMware Player from the keyboard input conversion targets.

(^|- )VMware Player$

Example Usage

In my case, I've personally configured to launch this tool on X-server startup. Here's how I have done this:

The above settings works for me, at least to a level that I can daily use it for my work :-)

Additional Notes

Technical Information


Related Information and Acknowledgement

Linux Input Subsystemの使い方
This page describes the usage of Linux Input Subsystem from applications. I would like to acknowledge that the tool provided here is implemented using the information provided on this site.
AutoHotKey script (emacs.ahk) for realizing Emacs keybindings on Win32 is distributed. I personally uses this script when I need to use Windows, and the idea of emacs.cpp is inspired from this script.
A more generalized keybinding configuration tool with customizable features. It includes Emacs-keybinding configuration file as a default, and I personally recommend using it instead of x11keymacs. It uses X11 functionalities for keyboard input handling, and seem to differ from the x11keymacs in many ways with respect to the implementation techniques.
窓使いの憂鬱 for Linux & Mac (Darwin)
Linux/Mac-version of "窓使いの憂鬱" is distributed on this site. I found from the souce code that it uses similar techniques for keyboard input processing as done by mine, using the Linux input subsystem. I found this after I finished implemented x11keymacs, and regret I should have added window title/class features on it instead of reinventing the wheel.


[ Back ]

Yashiro Takeshi <>
Last modified: Fri Nov 25 06:55:45 2011
Valid XHTML 1.0!