1

I have a japanese layout keyboard and I'd like to customize it to fit my need. Here is the xkb layout file I created.

default
partial alphanumeric_keys modifier_keys
xkb_symbols "jp106" {
    include "srvr_ctrl(fkey2vt)"
    include "keypad(numoperdecsep)"

    key <SCLK> {    [  Scroll_Lock      ]   };
    key <PAUS> {
    type= "PC_CONTROL_LEVEL2",
    symbols[Group1]= [ Pause, Break ]
    };

    key  <INS> {    [  Insert       ]   };
    key <HOME> {    [  Home         ]   };
    key <PGUP> {    [  Prior        ]   };
    key <DELE> {    [  Delete       ]   };
    key  <END> {    [  End          ]   };
    key <PGDN> {    [  Next         ]   };

    key   <UP> {    [  Up           ]   };
    key <LEFT> {    [  Left         ]   };
    key <DOWN> {    [  Down         ]   };
    key <RGHT> {    [  Right        ]   };

    replace modifier_map Control { Control_L, Control_R };
    replace modifier_map Shift { Shift_L, Shift_R };
    replace modifier_map Lock { Caps_Lock };
    replace modifier_map Mod1 { Alt_L };
    replace modifier_map Mod2 { Num_Lock };
    replace modifier_map Mod3 { Hyper_R };
    replace modifier_map Mod4 { Super_L, Super_R };
    replace modifier_map Mod5 { Mode_switch };

    key  <ESC> {    [ Escape    ]   };
    key <NMLK> {    [ Num_Lock  ]   };
    key <BKSP> {    [ BackSpace ]   };
    key  <TAB> {    [ Tab, ISO_Left_Tab ]   };
    key <RTRN> {    [ Return    ]   };
    key <LFSH> {    [ Shift_L   ]   };
    key <RTSH> {    [ Shift_R   ]   };
    key <LCTL> {    [ Control_L ]   };
    key <LWIN> {    [ Super_L   ]   };
    key <LALT> {    [ Alt_L     ]   };
    key <NFER> {    [ space     ]   };
    key <SPCE> {    [ Shift_R   ]   };
    key <XFER> {    [ Mode_switch ] };
    key <HKTG> {    [ Control_L ]   };
    key <RALT> {    [ Hyper_R   ]   };

    // t420 and lower 
    key <MENU> {    [ Super_R   ]   };
    // t430 and higher
    key <PRSC> {    [ Super_R   ]   };

    key <RCTL> {    [ Control_R ]   };


    key <AE01> { [ 1, exclam        ] };
    key <AE02> { [ 2, at            ], [ ampersand ] };
    key <AE03> { [ 3, numbersign    ], [ semicolon ] };
    key <AE04> { [ 4, dollar        ], [ colon ] };
    key <AE05> { [ 5, percent       ] };
    key <AE06> { [ 6, asciicircum ] };
    key <AE07> { [ 7, ampersand ] };
    key <AE08> { [ 8, asterisk      ] };
    key <AE09> { [ 9, parenright    ] };
    key <AE10> { [ 0,   parenright      ] };
    key <AE11> { [ minus, underscore        ] };
    key <AE12> { [ asciicircum, asciitilde] };
    key <AE13> { [ yen, bar ] };

    key <AD01> { [ q, Q         ], [ grave ] };
    key <AD02> { [ w, W         ], [ slash ] };
    key <AD03> { [ e, E         ], [ braceleft ] };
    key <AD04> { [ r, R         ], [ braceright ] };
    key <AD05> { [ t, T         ], [ quotedbl ] };
    key <AD06> { [ y, Y         ] };
    key <AD07> { [ u, U         ] };
    key <AD08> { [ i, I         ] };
    key <AD09> { [ o, O         ] };
    key <AD10> { [ p, P         ] };
    key <AD11> { [ at, grave        ] };
    key <AD12> { [ bracketleft, braceleft ] };

    key <CAPS> { [ Caps_Lock ] };

    key <AC01> { [ a, A         ], [ asciitilde ] };
    key <AC02> { [ s, S         ], [ question ] };
    key <AC03> { [ d, D         ], [ bracketleft ] };
    key <AC04> { [ f, F         ], [ bracketright ] };
    key <AC05> { [ g, G         ], [ apostrophe ] };
    key <AC06> { [ h, H         ] };
    key <AC07> { [ j, J         ] };
    key <AC08> { [ k, K         ] };
    key <AC09> { [ l, L         ] };
    key <AC10> { [ semicolon, colon ] };
    key <AC11> { [ colon, asterisk  ] };
    key <AC12> { [ bracketright, braceright ] };

    key <AB01> { [ z, Z         ] };
    key <AB02> { [ x, X         ], [ equal ] };
    key <AB03> { [ c, C         ], [ plus ] };
    key <AB04> { [ v, V         ], [ bar ] };
    key <AB05> { [ b, B         ], [ backslash ] };
    key <AB06> { [ n, N         ] };
    key <AB07> { [ m, M         ] };
    key <AB08> { [ comma,  less     ] };
    key <AB09> { [ period, greater  ] };
    key <AB10> { [ slash, question  ] };
    key <AB11> { [ backslash, underscore] };
};

However, these keys don't work as expected,

key <LWIN> {    [ Super_L   ]   };
key <NFER> {    [ space     ]   };
key <SPCE> {    [ Shift_R   ]   };
key <XFER> {    [ Mode_switch ] };
key <HKTG> {    [ Control_L ]   };
key <RALT> {    [ Hyper_R   ]   };

// t420 and lower 
key <MENU> {    [ Super_R   ]   };
// t430 and higher
key <PRSC> {    [ Super_R   ]   };

The modifiers are wrong too. This is what xmodmap shows,

❯ xmodmap
xmodmap:  up to 3 keys per modifier, (keycodes in parentheses):

shift       Shift_L (0x32),  Shift_R (0x3e)
lock        Caps_Lock (0x42)
control     Control_L (0x25),  Control_R (0x69)
mod1        Alt_L (0x40),  Alt_R (0x6c),  Meta_L (0xcd)
mod2        Num_Lock (0x4d)
mod3        Hyper_L (0xcf)
mod4        Super_L (0x85),  Super_R (0x86),  Super_L (0xce)
mod5        ISO_Level3_Shift (0x5c),  Mode_switch (0xcb)

I have put the layout file in /usr/share/X11/xkb/symbols/jpamos and have loaded the keymap using setxkbmap jpamos. I also have used localectl set-x11-keymap jpamos to persist it.

Any help is much much appreciated! Thanks!

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.