git clone https://gitweb.michael.orlitzky.com/emacs-keys.git
Files that can be used to alter your keyboard layout in the system console, within X.org, or anywhere else that uses xkb (for example, most Wayland compositors):
In other words, we put those keys where they lived on the space-cadet keyboard. This makes emacs (and any readline-based application) easier to use, I promise.
(The console map probably only works on i386 qwerty keyboards, because that's all I have.)
The files:
This affects the Linux system console and virtual terminals; that is, the things that you switch between with Ctrl-Alt-FN, and the thing that you're looking at before you start your graphical desktop environment. The console.map file is input for the loadkeys utility that is part of KBD project and is provided by sys-apps/kbd on Gentoo.
This affects the X.org system, and your graphical terminals. It should be fed into the xmodmap utility that is part of X.org and which is provided by x11-apps/xmodmap on Gentoo.
This is an xkb keyboard layout file and it affects anything that uses libxkbcommon for keyboard support. That of course includes X11 itself, but the main reason this file exists is to support Wayland. Under X11, the Xmodmap file is easier.
The build system installs each of these files to $(datadir)/emacs-keys. The console.map and Xmodmap files can be loaded directly from that location; for example,
user $ loadkeys /path/to/console.map
user $ xmodmap /path/to/Xmodmap
But you probably don't want to do that every time you log in.
For the Xmodmap file, you would typically add something like the following to your ~/.xinitrc,
emacsmodmap=/usr/share/emacs-keys/Xmodmap
if [ -f $emacsmodmap ]; then
xmodmap $emacsmodmap
xmodmap $emacsmodmap
fi
The call to xmodmap doesn't work unless you do it twice, and don't ask me why.
If you're lucky enough to use OpenRC, the console map can be loaded automatically. OpenRC starts a keymaps service at boot time. The configuration file for that service is usually located at /etc/conf.d/keymaps, and if you set, for example,
in there, then OpenRC will load the emacs keymap on top of your default one when the system boots.
Systemd can probably do this too, but you're on your own there.
The xkb layout needs to be installed where libxkbcommon will look for it. Rather than muck with system paths, we assume that you'll be configuring the keyboard for only one user (i.e. you). The per-user xkb configuration typically goes in $XDG_CONFIG_HOME/xkb, and the variable $XDG_CONFIG_HOME defaults to ~/.config in your home directory. Your ultimate goal is therefore to make the xkb/symbol/emacs-keys file available under ~/.config.
The best way to do this is with a symlink:
user $ ln -s /usr/share/emacs-keys/xkb/ ~/.config/
Now, to use it, all you have to do is tell whatever program you're using to use the emacs-keys xkb layout. For example, the Sway window manager can be configured with,
Other programs are configured similarly.