System76 EC firmware supports using custom keyboard layouts. For example, having the physical "Caps Lock" key function as "Escape" when pressed.
This only applies to the internal keyboard. External keyboards are not affected.
Advanced functionality, such as macros or QMK's Mod-Tap, are not supported.
You must be able to build and flash firmware. See the README if you have not built the firmware before.
To ensure compatibility with other system components (e.g. your current BIOS version), it's recommended to flash the same firmware version as you're currently using.
Determine the BIOS version using dmidecode. The BIOS version is formatted as
<date>_<revision>.
sudo dmidecode -t bios | grep VersionFrom the firmware-open repo, determine the EC commit used for the BIOS version.
git ls-tree <bios_rev> ecCheckout that commit in the EC repo and update the submodules.
git checkout <ec_rev>
git submodule update --recursiveDetermine the keyboard used for your model.
grep KEYBOARD src/board/system76/<model>/board.mkCopy the default layout file for the keyboard to a separate file in the keymap directory.
cp src/keyboard/system76/<keyboard>/keymap/default.c src/keyboard/system76/<keyboard>/keymap/<custom>.cThe name of the keymap can be anything. Following QMK convention, the file name could be your username.
A keymap file is a C file that defines the position of key and its function.
Only the LAYOUTs should be modified.
There are 2 layers in a keymap file.
KEYMAP[0]: The firstLAYOUTdefines the default layerKEYMAP[1]: The secondLAYOUTdefines the function layer
A KT_FN key must be assigned on the first layer in order to access the second
layer. The KT_FN key must be held to use keys on the second layer.
Change one key at a time to avoid losing your place.
Some related files are:
src/common/include/common/keymap.h: Defines the key scancodessrc/keyboard/system76/<keyboard>/include/board/keymap.h: Defines the keyboard matrix
Build the firmware specifying the KEYMAP you have added.
make BOARD=system76/lemp9 KEYMAP=customUse a config file to simplify this. In the EC project's root directory, create
a file named config.mk. Define the BOARD and KEYMAP variables.
BOARD?=system76/lemp9
KEYMAP?=customThen building the firmware only requires calling make.
# Make will read config.mk to determine which board and keymap to use.
makeSee flashing firmware for details.
Do not use the keyboard or touchpad while it is flashing.
The system will power off as part of the flash process. Turn it back on after it has powered off.
The keyboard can now be used with your new layout.
If your layout does not work as you intended, only the internal keyboard will be affected. An external USB keyboard or SSH session can be used to correct the layout and reflash the firmware.