Followed http://askubuntu.com/questions/482678/how-to-add-a-new-keyboard-layout-custom-keyboard-layout-definition
Create /usr/share/X11/xkb/symbols/nh2-thinkpad
with content:
// based on a keyboard map from an 'xkb/symbols/gb' file
default partial alphanumeric_keys
xkb_symbols "basic" {
// Makes Caps Lock become the "Hyper" key, and be the Mod3 modifier.
// This allows me to easily use Mod3 in the i3 window manager without
// messing with `setxkbmap`/`xmodmap`; it even keeps working when
// re-plugging the keyboard.
name[Group1]="English (UK) nh2 Thinkpad";
include "gb"
key <CAPS> { [ Hyper_L ] };
modifier_map Mod3 { <CAPS> };
modifier_map Mod3 { <HYPR> };
include "level3(ralt_switch_multikey)"
};
To /usr/share/X11/xkb/rules/evdev.xml
add an entire <layout>
section, copied from the <layout>
section that contains <name>gb</name>
, but just below that gb
<layout>
section. That means, put in:
<layout>
<configItem>
<name>gb-nh2-thinkpad</name>
<shortDescription>en</shortDescription>
<description>English (UK) nh2 Thinkpad</description>
<languageList>
<iso639Id>eng</iso639Id>
</languageList>
</configItem>
<variantList>
</variantList>
</layout>
The keyboard layout should now be available in the Unity/Gnome/whatever layout selection menu. It even appears in the GDM login screen!