Other posts in this series:

Examinining the Current Keyboard Map

To get some rough bearings on how keys are currently mapped, install xev:

pacman -S xorg-xev

Run it and you’ll see a new window titled “Event Tester.” All keyboard and mouse events are logged when this window has the focus. Try pressing some keys. You’ll see that:

  • Option maps to Alt.
  • Command maps to Super.
  • Function keys map to events like “XF86MonBrightnessUp” and “XF86AudioMute”.
  • Function keys in combination with the “fn” key map to F1, F2, etc.

fn and the Function Keys

If you’d like to have the function keys be function keys by default and use their “application function” (e.g., volume down) only when the fn key is pressed, do the following and reboot:

echo "options hid_apple fnmode=2" > /etc/modprobe.d/hid_apple.conf

Other Configuration: localectl

The localectl utility is great for basic keyboard configuration. When using it to set the X keymap, you must pass the following:

  1. layout
  2. model
  3. variant
  4. options

Layout is generally your two-digit country code such as “us”. Run localectl list-x11-keymap-layouts for options.

Modal defaults to “pc105”, and I’ve found it best to stick with that so far.

Use variant to specify a layout variant such as “dvorak”. If you do not want to use a variant, pass an empty string.

Options allow you to specify additional mapping rules. You can pass multiple options in a comma-separated list. Run localectl list-x11-keymap-options for a full list. The ones that I use are:

  • ctrl:nocaps maps the caps lock key to control.
  • terminate:ctrl_alt_bksp allows you to force quit out of X by using Ctrl+Alt+Backspace.

Thus, for standard US QWERTY set up, run something this:

localectl set-x11-keymap us pc105 "" ctrl:nocaps,terminate:ctrl_alt_bksp

For Dvorak, run:

localectl set-x11-keymap us pc105 dvorak ctrl:nocaps,terminate:ctrl_alt_bksp

This will generate a file called /etc/X11/xorg.conf.d/00-keyboard.conf which is loaded by X when it starts.

X Keyboard Repeat Rate

The best way to set the repeat rate for Xorg is to pass the the -ardelay (XKB autorepeat delay ms) and -arinterval (XKB autorepeat interval ms) arguments.

The startx command looks for a ~/.xserverrc to start the X server. If it cant find it, it looks to /etc/X11/xinit/xserverrc, shown here:

#!/bin/sh
if [ -z "$XDG_VTNR" ]; then
  exec /usr/bin/X -nolisten tcp "$@"
else
  exec /usr/bin/X -nolisten tcp "$@" vt$XDG_VTNR
fi

You can see that it uses “$@” to pass whatever arguments it received through to X. So, we can preserve the default behavior and add to it our keyboard repeat settings by creating a .xserverrc in our home directory:

#!/bin/sh
exec /bin/sh /etc/X11/xinit/xserverrc -ardelay 200 -arinterval 25