Remap function keys to Chromebook media keys on Linux. This program uses evdev
and uinput
to perform the key mapping at close to kernel level. It is more flexible than HWDB scancode mapping. Unlike XKB mappings, this program work in the Linux console and the GDM login screen.
Features:
-
Default mapping of function key to the original Chromebook media keys
-
Press the FN key to toggle the FN locked mode
-
Press FN+key to select the second level alternate key
-
-
Support third-level key mapping with FN+Shift+key combinations
- FN+Shift+brightness up/down control keyboard backlights
-
Optionally take over an keyboard LED as the FN key lock LED.
Download the Go SDK from the Downloads page.
Following the install instructions.
go mod download
go build
In case you don't have the C headers for cgo, you can build the pure Go version.
CGO_ENABLED=0 go build
First pick a key as the FN
key. I don't use the Lock
key (at the upper left corner) on my Chromebook, so I turned it into the FN
key.
./chromekey -dump_config > chromekey.config
Stop any running instance to release the grab on the keyboard device first.
./chromekey -show_key
fn_key: KEY_F13
fn_enabled: true
third_level_key: KEY_LEFTSHIFT
third_level_key: KEY_RIGHTSHIFT
Use FN+Shift+F6/F7
for keyboard backlight adjustment:
third_level_key_map: {
from: KEY_F6
to: KEY_KBDILLUMDOWN
}
third_level_key_map: {
from: KEY_F7
to: KEY_KBDILLUMUP
}
For example, press FN+backspace to send the DELETE key:
mod_key_map: {
from: KEY_BACKSPACE
to: KEY_DELETE
}
NOTE: Don't use this option if you have an external USB keyboard with a numpad.
use_led: NUML
sudo cp ./chromekey /usr/local/bin
sudo cp chromekey.config /usr/local/etc/
sudo tee /etc/systemd/system/chromekey.service <<EOF
[Service]
Type=simple
ExecStart=/usr/local/bin/chromekey -config_file=/usr/local/etc/chromekey.config
EOF
sudo tee /etc/udev/rules.d/99-chromekey.rules <<EOF
ACTION=="add", ATTRS{name}=="AT Translated Set 2 keyboard", TAG+="systemd", ENV{SYSTEMD_WANTS}="chromekey.service"
EOF
sudo cp config/chromekey.completion /etc/bash_completion.d/chromekey
Install a Lock Keys Gnome Shell extension to show LED status on screen.