Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@ivan-krukov
Last active March 6, 2021 03:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save ivan-krukov/2b26dca3c68bb98f906e to your computer and use it in GitHub Desktop.
Save ivan-krukov/2b26dca3c68bb98f906e to your computer and use it in GitHub Desktop.
My favourite keymap

#Custom Keymap (Lenovo T430)

This will apply settings for both system console and Xorg server.

  • CapsLock will become an extra Esc
  • Home will be switched with PageUp
  • End will be switched with PageDown

This makes sense for the Lenovo T430, where PageUp and PageDown are right next to the arrow keys.

Filepaths are Arch-specific

##Usage

make
sudo make install
# Linux-specific (and language-independent) keys
#
# This file describes function keys, console switching keys,
# keypad, cursor keys, and SysRq, ScrollLock, Pause
#
# It does not use the AltGr modifier, so that the user can opt
# to have both Alt keys produce the same effect.
# As a consequence, the Hex_* keys are missing, as are
# control altgr keycode 83 = Boot
# control altgr keycode 111 = Boot
#
# One culture-specific item that will be overridden in many keymaps
# is the KP_Period: many countries have a KP_Comma instead.
#
# One user-preference item will be the function of the Delete key.
#
# Old keyboards have 10 function keys, and keymaps have
# sometimes used shift+F1 = F11, and sometimes shift+F1 = F13.
# Here we assume an enhanced keyboard (with 12 function keys).
#
plain keycode 59 = F1
plain keycode 60 = F2
plain keycode 61 = F3
plain keycode 62 = F4
plain keycode 63 = F5
plain keycode 64 = F6
plain keycode 65 = F7
plain keycode 66 = F8
plain keycode 67 = F9
plain keycode 68 = F10
plain keycode 87 = F11
plain keycode 88 = F12
shift keycode 59 = F13
shift keycode 60 = F14
shift keycode 61 = F15
shift keycode 62 = F16
shift keycode 63 = F17
shift keycode 64 = F18
shift keycode 65 = F19
shift keycode 66 = F20
shift keycode 67 = F21
shift keycode 68 = F22
shift keycode 87 = F23
shift keycode 88 = F24
control keycode 59 = F25
control keycode 60 = F26
control keycode 61 = F27
control keycode 62 = F28
control keycode 63 = F29
control keycode 64 = F30
control keycode 65 = F31
control keycode 66 = F32
control keycode 67 = F33
control keycode 68 = F34
control keycode 87 = F35
control keycode 88 = F36
#
# The canonical assignment for F37-F48 uses
# control shift keycode 59 = F37
# etc. If you want that, load linux-keys-extd.inc
#
# Both Alt+Fn and Control+Alt+Fn switch to Console n
# (in order to please Linux / dosemu / X).
# Here Consoles 1..12. For 13..24 load linux-keys-extd.inc
#
alt keycode 59 = Console_1
alt keycode 60 = Console_2
alt keycode 61 = Console_3
alt keycode 62 = Console_4
alt keycode 63 = Console_5
alt keycode 64 = Console_6
alt keycode 65 = Console_7
alt keycode 66 = Console_8
alt keycode 67 = Console_9
alt keycode 68 = Console_10
alt keycode 87 = Console_11
alt keycode 88 = Console_12
control alt keycode 59 = Console_1
control alt keycode 60 = Console_2
control alt keycode 61 = Console_3
control alt keycode 62 = Console_4
control alt keycode 63 = Console_5
control alt keycode 64 = Console_6
control alt keycode 65 = Console_7
control alt keycode 66 = Console_8
control alt keycode 67 = Console_9
control alt keycode 68 = Console_10
control alt keycode 87 = Console_11
control alt keycode 88 = Console_12
#
# Keypad keys
#
keycode 69 = Num_Lock
keycode 98 = KP_Divide
keycode 55 = KP_Multiply
keycode 74 = KP_Subtract
keycode 78 = KP_Add
keycode 96 = KP_Enter
#
keycode 71 = KP_7
keycode 72 = KP_8
keycode 73 = KP_9
keycode 75 = KP_4
keycode 76 = KP_5
keycode 77 = KP_6
keycode 79 = KP_1
keycode 80 = KP_2
keycode 81 = KP_3
keycode 82 = KP_0
#
keycode 83 = KP_Period # or KP_Comma
control alt keycode 83 = Boot
#
alt keycode 71 = Ascii_7
alt keycode 72 = Ascii_8
alt keycode 73 = Ascii_9
alt keycode 75 = Ascii_4
alt keycode 76 = Ascii_5
alt keycode 77 = Ascii_6
alt keycode 79 = Ascii_1
alt keycode 80 = Ascii_2
alt keycode 81 = Ascii_3
alt keycode 82 = Ascii_0
#
# The four cursor keys
#
keycode 103 = Up
keycode 105 = Left
keycode 106 = Right
keycode 108 = Down
alt keycode 103 = KeyboardSignal
alt keycode 105 = Decr_Console
alt keycode 106 = Incr_Console
#
# The six edit keys
#
keycode 110 = Insert
# This was Home
keycode 102 = PageUp # Find
# This was PageUp
keycode 104 = Home # Prior
keycode 111 = Remove
# This was End
keycode 107 = PageDown # Select
# This was PageDown
keycode 109 = End # Next
shift keycode 104 = Scroll_Backward
shift keycode 109 = Scroll_Forward
control alt keycode 111 = Boot
#
# The three system keys
#
keycode 84 = Last_Console # Alt+SysRq/PrintScrn
#keycode 99 = VoidSymbol # SysRq/PrintScrn
keycode 99 = Compose # SysRq/PrintScrn
alt keycode 99 = Control_backslash
control keycode 99 = Control_backslash
plain keycode 70 = Scroll_Lock
shift keycode 70 = Show_Memory
control keycode 70 = Show_State
alt keycode 70 = Show_Registers
keycode 101 = Break # Ctrl+Break/Pause
keycode 119 = Pause # Break/Pause
CONSOLE_DIR=/usr/share/kbd/keymaps/i386
XORG_DIR=/usr/share/X11/xkb
all: archive
archive:
gzip -c us.map > us.map.gz
clean:
rm us.map.gz
install: archive
@echo "Applying console keymap"
cp us.map.gz ${CONSOLE_DIR}/qwerty/
cp linux-keys-bare.inc ${CONSOLE_DIR}/include/
@echo "Applying X keymap"
cp pc ${XORG_DIR}/symbols
@echo "done"
default partial alphanumeric_keys modifier_keys
xkb_symbols "pc105" {
key <ESC> { [ Escape ] };
// The extra key on many European keyboards:
key <LSGT> { [ less, greater, bar, brokenbar ] };
// The following keys are common to all layouts.
key <BKSL> { [ backslash, bar ] };
key <SPCE> { [ space ] };
include "srvr_ctrl(fkey2vt)"
include "pc(editing)"
include "keypad(x11)"
key <BKSP> { [ BackSpace, BackSpace ] };
key <TAB> { [ Tab, ISO_Left_Tab ] };
key <RTRN> { [ Return ] };
// This was Caps_Lock
key <CAPS> { [ Escape ] };
key <NMLK> { [ Num_Lock ] };
key <LFSH> { [ Shift_L ] };
key <LCTL> { [ Control_L ] };
key <LWIN> { [ Super_L ] };
key <RTSH> { [ Shift_R ] };
key <RCTL> { [ Control_R ] };
key <RWIN> { [ Super_R ] };
key <MENU> { [ Menu ] };
// Beginning of modifier mappings.
modifier_map Shift { Shift_L, Shift_R };
modifier_map Lock { Caps_Lock };
modifier_map Control{ Control_L, Control_R };
modifier_map Mod2 { Num_Lock };
modifier_map Mod4 { Super_L, Super_R };
// Fake keys for virtual<->real modifiers mapping:
key <LVL3> { [ ISO_Level3_Shift ] };
key <MDSW> { [ Mode_switch ] };
modifier_map Mod5 { <LVL3>, <MDSW> };
key <ALT> { [ NoSymbol, Alt_L ] };
include "altwin(meta_alt)"
key <META> { [ NoSymbol, Meta_L ] };
modifier_map Mod1 { <META> };
key <SUPR> { [ NoSymbol, Super_L ] };
modifier_map Mod4 { <SUPR> };
key <HYPR> { [ NoSymbol, Hyper_L ] };
modifier_map Mod4 { <HYPR> };
// End of modifier mappings.
key <OUTP> { [ XF86Display ] };
key <KITG> { [ XF86KbdLightOnOff ] };
key <KIDN> { [ XF86KbdBrightnessDown ] };
key <KIUP> { [ XF86KbdBrightnessUp ] };
};
hidden partial alphanumeric_keys
xkb_symbols "editing" {
key <PRSC> {
type= "PC_ALT_LEVEL2",
symbols[Group1]= [ Print, Sys_Req ]
};
key <SCLK> { [ Scroll_Lock ] };
key <PAUS> {
type= "PC_CONTROL_LEVEL2",
symbols[Group1]= [ Pause, Break ]
};
key <INS> { [ Insert ] };
//This was Home
key <HOME> { [ Prior ] };
//This was Prior
key <PGUP> { [ Home ] };
key <DELE> { [ Delete ] };
// This was End
key <END> { [ Next ] };
// This was Next
key <PGDN> { [ End ] };
key <UP> { [ Up ] };
key <LEFT> { [ Left ] };
key <DOWN> { [ Down ] };
key <RGHT> { [ Right ] };
};
# us.map
keymaps 0-2,4-6,8-9,12
alt_is_meta
include "qwerty-layout"
include "linux-with-alt-and-altgr"
include "compose.latin1"
include "euro1.map"
strings as usual
keycode 1 = Escape
keycode 2 = one exclam
keycode 3 = two at at nul nul
keycode 4 = three numbersign
control keycode 4 = Escape
keycode 5 = four dollar dollar Control_backslash
keycode 6 = five percent
control keycode 6 = Control_bracketright
keycode 7 = six asciicircum
control keycode 7 = Control_asciicircum
keycode 8 = seven ampersand braceleft Control_underscore
keycode 9 = eight asterisk bracketleft Delete
keycode 10 = nine parenleft bracketright
keycode 11 = zero parenright braceright
keycode 12 = minus underscore backslash Control_underscore Control_underscore
keycode 13 = equal plus
keycode 14 = Delete
keycode 15 = Tab
shift keycode 15 = Meta_Tab
keycode 26 = bracketleft braceleft
control keycode 26 = Escape
keycode 27 = bracketright braceright asciitilde Control_bracketright
keycode 28 = Return
alt keycode 28 = Meta_Control_m
keycode 29 = Control
keycode 39 = semicolon colon
keycode 40 = apostrophe quotedbl
control keycode 40 = Control_g
keycode 41 = grave asciitilde
control keycode 41 = nul
keycode 42 = Shift
keycode 43 = backslash bar
control keycode 43 = Control_backslash
keycode 51 = comma less
keycode 52 = period greater
keycode 53 = slash question
control keycode 53 = Control_underscore
control shift keycode 53 = Delete
keycode 54 = Shift
keycode 56 = Alt
keycode 57 = space
control keycode 57 = nul
keycode 58 = Escape
keycode 86 = less greater bar
keycode 97 = Control
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment