Ubuntu – Key ‘@’ (Keycode 49) and key ‘<' (keycode 94) are inverted on macbookPro keyboard

keyboardkeyboard-layoutmacbook proxkb

I am running Ubuntu 16.10 on a MacbookPro and keys 49 and 94 are inverted… I resolved this problem with xmodmap, but this won't apply permanently. After some research I found xmodmap is no longuer use by Ubuntu but xkb instead. So I searched in the configuration of xkb and I found in the config file /usr/share/X11/xkb/keycodes/macintosh this lines :

xkb_keycodes "badmap" {
    <TLDE> =  94;
    <LSGT> =  49;
};

xkb_keycodes "goodmap" {
    <TLDE> =  49;
    <LSGT> =  94;
};

This is exactly my problem, this two keys are inverted. So I wondering if I can't change my layout configuration with the param badmap.


The ouput of setxkbmap -query -v 10

Setting verbose level to 10
locale is C
Trying to load rules file ./rules/evdev...
Trying to load rules file /usr/share/X11/xkb/rules/evdev...
Success.
Applied rules from evdev:
rules:      evdev
model:      pc105
layout:     fr,fr,us
variant:    mac,oss,
Trying to build keymap using the following components:
keycodes:   evdev+aliases(azerty)
types:      complete
compat:     complete
symbols:    pc+fr(mac)+fr(oss):2+us:3+inet(evdev)
geometry:   pc(pc105)
rules:      evdev
model:      pc105
layout:     fr,fr,us
variant:    mac,oss,

Best Answer

I accidentally stumbled upon this patch, which led me to the solution:

Open /etc/default/keyboard for editing and set:

XKBOPTIONS="apple:badmap"

At next reboot those keys will be switched.