How to set up a MacBook Pro keyboard on Linux

Gagarine Yaikhom

06 January 2024, Friday

The following is one way to set up the MacBook Pro keyboard with the following UK (British) English Layout:

Source: keyshorts.com

Create configuration

Create file:

sudo emacs -nw /usr/share/X11/xkb/symbols/uk_mac

with contents:

default partial alphanumeric_keys
xkb_symbols "mac" {
    include "latin"
    name[Group1]= "English (UK, Macintosh)";
    key <LSGT> {[   grave, asciitilde ]};
    key <AE02> {[       2,         at,   EuroSign ]};
    key <AE03> {[       3, numbersign, sterling ]};
    key <TLDE> {[ section,  plusminus ]};

    include "level3(ralt_switch)"
    include "level3(enter_switch)"
};

Note that since I use ‘#’ more than ‘£’, I have set up the configuration so that typing ‘#’ only requires a shift key, whereas, typing ‘£’ requires the less convenient right option key.

Applying the configuration

Run following to apply the configuration.

setxkbmap uk_mac mac

Use by default

For the i3wm tiling window manager, I add the following in ~/.config/i3/config:

exec --no-startup-id setxkbmap uk_mac mac

References

https://bbs.archlinux.org/viewtopic.php?id=290587