xkb - How to add a new keyboard layout (Custom keyboard layout definition) - Ask Ubuntu


i want copy keyboard layout in /usr/share/x11/xkb/symbols/ , change , produce new layout it.

how can add new keyboard layout (named e.g. "mylayout")?

update #1:

files changed add new layout:

  • /usr/share/x11/xkb/symbols/irwinxp (originally same ir):

    // iranian keyboard layout  //////////////////////////////////////// // persian layout, // based on // information technology – layout of persian letters , symbols on computer keyboards // isiri 9147 – 1st edition // institute of standards , industrial research of iran // http://www.isiri.org/userstd/downloadstd.aspx?id=9147 // http://behnam.esfahbod.info/standards/isiri-keyboard-9147.pdf // // author: behnam esfahbod <behnam@esfahbod.info> //  default  partial alphanumeric_keys xkb_symbols "pes" {     name[group1]= "persian";      include "ir(pes_part_basic)"     include "ir(pes_part_ext)"      include "nbsp(zwnj2nb3nnb4)"     include "level3(ralt_switch)" };   partial alphanumeric_keys xkb_symbols "pes_keypad" {     name[group1]= "persian (with persian keypad)";      include "ir(pes_part_basic)"     include "ir(pes_part_keypad)"      include "nbsp(zwnj2nb3nnb4)"     include "level3(ralt_switch)" };  partial hidden alphanumeric_keys xkb_symbols "pes_part_basic" {      // persian digits     key <ae01> { [ farsi_1, exclam,     grave           ] };     key <ae02> { [ farsi_2, 0x100066c,  @          ] };     key <ae03> { [ farsi_3, 0x100066b,  numbersign      ] };     key <ae04> { [ farsi_4, 0x100fdfc,  dollar          ] };     key <ae05> { [ farsi_5, 0x100066a,  percent         ] };     key <ae06> { [ farsi_6, multiply,   asciicircum     ] };     key <ae07> { [ farsi_7, arabic_comma,   ampersand       ] };     key <ae08> { [ farsi_8, asterisk,   enfilledcircbullet  ] };     key <ae09> { [ farsi_9, parenright, 0x100200e       ] };     key <ae10> { [ farsi_0, parenleft,  0x100200f       ] };      // persian letters , symbols     key <ad01> { [ arabic_dad,      arabic_fathatan,    degree      ] }; // 2: arabic_sukun     key <ad02> { [ arabic_sad,      arabic_dammatan,    voidsymbol  ] }; // 2: arabic_dammatan     key <ad03> { [ arabic_theh,     arabic_kasratan,    0x13a4      ] }; // 2: arabic_kasratan     key <ad04> { [ arabic_qaf,      arabic_fathatan,    voidsymbol  ] };     key <ad05> { [ arabic_feh,      arabic_comma,       voidsymbol  ] }; // 2: arabic_damma     key <ad06> { [ arabic_ghain,    arabic_semicolon,   voidsymbol  ] }; // 2: arabic_kasra     key <ad07> { [ arabic_ain,      arabic_fatha,       voidsymbol  ] };     key <ad08> { [ arabic_heh,      arabic_hamza_above, 0x100202d   ] }; // 2: arabic_shadda     key <ad09> { [ arabic_khah,     bracketright,       0x100202e   ] };     key <ad10> { [ arabic_hah,      bracketleft,        0x100202c   ] };     key <ad11> { [ arabic_jeem,     braceright,     0x100202a   ] };     key <ad12> { [ arabic_tcheh,    braceleft,      0x100202b   ] };      key <ac01> { [ arabic_sheen,    arabic_fatha,       voidsymbol  ] }; // 2: arabic_hamzaonwaw     key <ac02> { [ arabic_seen,     arabic_damma,       voidsymbol  ] }; // 2: arabic_hamzaonyeh     key <ac03> { [ farsi_yeh,       arabic_kasra,       arabic_alefmaksura ] }; // 2: arabic_yeh     key <ac04> { [ arabic_beh,      arabic_shadda,  voidsymbol  ] }; // 1: arabic_hamzaunderalef     key <ac05> { [ arabic_lam,      0x10006c0,  voidsymbol  ] };// 2: arabic_hamzaonalef     key <ac06> { [ arabic_alef,     arabic_maddaonalef, 0x1000671   ] };     key <ac07> { [ arabic_teh,      arabic_tehmarbuta,  voidsymbol  ] };     key <ac08> { [ arabic_noon,     guillemotright,     0x100fd3e   ] };     key <ac09> { [ arabic_meem,     guillemotleft,      0x100fd3f   ] };     key <ac10> { [ arabic_keheh,    colon,          semicolon   ] };     key <ac11> { [ arabic_gaf,      quotedbl,       quotedbl    ] }; // 2: arabic_semicolon      key <ab01> { [ arabic_zah,      arabic_kaf,     voidsymbol  ] };     key <ab02> { [ arabic_tah,      0x1000653,      voidsymbol  ] };     key <ab03> { [ arabic_zain,     arabic_jeh,     voidsymbol  ] };     key <ab04> { [ arabic_ra,       arabic_hamzaonwaw   ,0x1000656  ] }; // 2: arabic_superscript_alef ٰ     key <ab05> { [ arabic_thal,     0x100200c,      0x100200d   ] };     key <ab06> { [ arabic_dal,      arabic_hamza_above, arabic_hamza_below  ] };     key <ab07> { [ arabic_hamzaonyeh,   arabic_hamza,       ellipsis    ] }; // 1: arabic_peh     key <ab08> { [ arabic_waw,      greater,        comma       ] };     key <ab09> { [ period,      less,           apostrophe  ] };     key <ab10> { [ slash,       arabic_question_mark,   question    ] };      key <tlde> { [ 0x100200d,       division,       asciitilde  ] };     key <ae11> { [ minus,       arabic_tatweel,     underscore  ] };     key <ae12> { [ equal,       plus,           0x1002212   ] };     key <bksl> { [ arabic_peh,      bar,            0x1002010   ] }; // 1: backslash };  partial hidden alphanumeric_keys xkb_symbols "pes_part_ext" {      // persian , ascii digits     key <ae01> { [ 0x10006f1,   exclam,     grave,          1   ] };     key <ae02> { [ 0x10006f2,   0x100066c,  at,         2   ] };     key <ae03> { [ 0x10006f3,   0x100066b,  numbersign,     3   ] };     key <ae04> { [ 0x10006f4,   0x100fdfc,  dollar,         4   ] };     key <ae05> { [ 0x10006f5,   0x100066a,  percent,        5   ] };     key <ae06> { [ 0x10006f6,   multiply,   asciicircum,        6   ] };     key <ae07> { [ 0x10006f7,   arabic_comma,   ampersand,      7   ] };     key <ae08> { [ 0x10006f8,   asterisk,   enfilledcircbullet, 8   ] };     key <ae09> { [ 0x10006f9,   parenright, 0x100200e,      9   ] };     key <ae10> { [ 0x10006f0,   parenleft,  0x100200f,      0   ] }; };  partial hidden alphanumeric_keys xkb_symbols "pes_part_keypad" {      // persian digits , mathematical operators     key <kpdv> { [ division,    xf86_ungrab ] };     key <kpmu> { [ multiply,    xf86_cleargrab  ] };     key <kpsu> { [ 0x1002212,   xf86_prev_vmode ] };     key <kpad> { [ plus,    xf86_next_vmode ] };      key <kpen> { [ kp_enter ] };     key <kpeq> { [ equal    ] };      key <kp7>  { [ kp_home, 0x10006f7   ] };     key <kp8>  { [ kp_up,   0x10006f8   ] };     key <kp9>  { [ kp_prior,    0x10006f9   ] };      key <kp4>  { [ kp_left, 0x10006f4   ] };     key <kp5>  { [ kp_begin,    0x10006f5   ] };     key <kp6>  { [ kp_right,    0x10006f6   ] };      key <kp1>  { [ kp_end,  0x10006f1   ] };     key <kp2>  { [ kp_down, 0x10006f2   ] };     key <kp3>  { [ kp_next, 0x10006f3   ] };      key <kp0>  { [ kp_insert,   0x10006f0   ] };     key <kpdl> { [ kp_delete,   0x100066b   ] }; };   //////////////////////////////////////// // kurdish layout  partial alphanumeric_keys xkb_symbols "ku" {     include "tr(ku)"     name[group1]= "kurdish (iran, latin q)"; };  partial alphanumeric_keys xkb_symbols "ku_f" {     include "tr(ku_f)"     name[group1]= "kurdish (iran, f)"; };  partial alphanumeric_keys xkb_symbols "ku_alt" {     include "tr(ku_alt)"     name[group1]= "kurdish (iran, latin alt-q)"; };  //////////////////////////////////////// // kurdish soranî bahdînî (arabic) keyboard layout, // based on kurdî soranî bahdînî keyboard kurditgroup // based on national iranian keyboard standard (isiri 2901:1994), // additions. // // copyright (c) 2006 erdal ronahî, published under gpl v2 // // special copyright note: author explicitly permitted license  // layout under mit/x11 license, details see // https://bugs.freedesktop.org/show_bug.cgi?id=9541 // // author: erdal ronahî  <erdal.ronahi@gmail.com> // // kurdish arabic-latin layout soranî  partial alphanumeric_keys xkb_symbols "ku_ara" {     name[group1]= "kurdish (iran, arabic-latin)";      // other 3-level symbols     key <tlde> { [ 0x100200d,       division,       asciitilde  ] };     key <bksl> { [ backslash,       bar,            ccedilla, ccedilla  ] };      // digits     key <ae01> { [ 1,   exclam,     0x10006f1,  grave       ] };     key <ae02> { [ 2,   at,         0x10006f2,  @      ] };     key <ae03> { [ 3,   numbersign, 0x10006f3,  0x100066b   ] };     key <ae04> { [ 4,   dollar,     0x10006f4,  0x100fdfc   ] };     key <ae05> { [ 5,   percent,    0x10006f5,  0x100066a   ] };     key <ae06> { [ 6,   asciicircum,    0x10006f6,  multiply    ] };     key <ae07> { [ 7,   ampersand,  0x10006f7,  arabic_comma    ] };     key <ae08> { [ 8,   asterisk,   0x10006f8,  enfilledcircbullet  ] };     key <ae09> { [ 9,   parenright, 0x10006f9,  0x100200e   ] };     key <ae10> { [ 0,   parenleft,  0x10006f0,  0x100200f   ] };     key <ae11> { [ minus,       arabic_tatweel,     underscore  ] };     key <ae12> { [ equal,       plus,           0x1002212   ] };      key <ad01> { [         arabic_qaf,            x,  q,  q ] };     key <ad02> { [         arabic_waw,            x,  w,  w ] };     key <ad03> { [          0x10006d5,   arabic_heh,  e,  e ] };     key <ad04> { [         arabic_ra ,    0x1000695,  r,  r ] };     key <ad05> { [         arabic_teh,   arabic_tah,  t,  t ] };     key <ad06> { [          0x10006cc,    0x10006ce,  y,  y ] };     key <ad07> { [  arabic_hamzaonyeh, arabic_hamza,  u,  u ] };     key <ad08> { [         arabic_hah,   arabic_ain,  i,  ] };     key <ad09> { [          0x10006c6, arabic_hamzaonwaw,  o,  o ] };     key <ad10> { [          0x100067e,  arabic_theh,  p,  p ] };     key <ad11> { [ bracketright,    braceright, ucircumflex, ucircumflex    ] };     key <ad12> { [ bracketleft,     braceleft,  scedilla, scedilla  ] };      key <ac01> { [ arabic_alef, arabic_maddaonalef, a,    ] };     key <ac02> { [ arabic_seen,     arabic_sheen,   s, s    ] };     key <ac03> { [  arabic_dal,     arabic_thal,    d, d    ] };     key <ac04> { [  arabic_feh, arabic_hamzaunderalef,  f, f    ] };     key <ac05> { [   0x10006af,     arabic_ghain,   g, g    ] };     key <ac06> { [  arabic_heh,     0x100200c,  h, h    ] };     key <ac07> { [   0x1000698, arabic_hamzaonalef, j, j    ] };     key <ac08> { [   0x10006a9,     arabic_kaf, k, k    ] };     key <ac09> { [  arabic_lam,     0x10006b5,  l, l    ] };     key <ac10> { [  arabic_semicolon,   colon,      ecircumflex, ecircumflex    ] };     key <ac11> { [  apostrophe,     quotedbl,   icircumflex, icircumflex    ] };      key <ab01> { [ arabic_zain,     arabic_dad, z, z    ] };     key <ab02> { [ arabic_khah,     arabic_sad, x, x    ] };     key <ab03> { [ arabic_jeem,     0x1000686,  c, c    ] };     key <ab04> { [   0x10006a4,     arabic_zah, v, v    ] };     key <ab05> { [ arabic_beh,      0x1000649,  b, b    ] };     key <ab06> { [ arabic_noon, arabic_tehmarbuta,  n, n    ] };     key <ab07> { [ arabic_meem, arabic_tatweel,     m, m    ] };     key <ab08> { [ arabic_comma,    greater,    comma       ] };     key <ab09> { [ period,      less,       apostrophe  ] };     key <ab10> { [ slash,       arabic_question_mark,   question    ] };      include "nbsp(zwnj2nb3)"     include "level3(ralt_switch)" };  // extras:  ///////////////////////////////////////////////////////////////////////////////// // // generated keyboard layout file keyboard layout editor. // more software, see http://code.google.com/p/keyboardlayouteditor // // version 0.2, fixed ad09. // // layout ernst tremel, http://ubuntuforums.org/showpost.php?p=9365469&postcount=32 // creation of file simos xenitellis.  partial alphanumeric_keys xkb_symbols "ave" {     name[group1] = "avestan";      key <ab01> { [ u10b30,         u10b32 ] }; // 𐬰 𐬲      key <ab02> { [ u10b11,         u10b12 ] }; // 𐬑 𐬒      key <ab03> { [ u10b17,          ue102 ] }; // 𐬗       key <ab04> { [ u10b2c,         u10b13 ] }; // 𐬬 𐬓      key <ab05> { [ u10b20,         u10b21 ] }; // 𐬠 𐬡      key <ab06> { [ u10b25,         u10b27 ] }; // 𐬥 𐬧      key <ab07> { [ u10b28,         u10b29 ] }; // 𐬨 𐬩      key <ab08> { [ u10b3c,         u10b39 ] }; // 𐬼 𐬹      key <ab09> { [ u10b3e,         u10b3d ] }; // 𐬾 𐬽      key <ab10> { [ u10b3f, periodcentered ] }; // 𐬿 ·       key <ac01> { [ u10b00,         u10b01 ] }; // 𐬀 𐬁      key <ac02> { [ u10b2f,         u10b31 ] }; // 𐬯 𐬱      key <ac03> { [ u10b1b,         u10b1c ] }; // 𐬛 𐬜      key <ac04> { [ u10b1f,         u10b16 ] }; // 𐬟 𐬖      key <ac05> { [ u10b14,         u10b15 ] }; // 𐬔 𐬕      key <ac06> { [ u10b35,          ue100 ] }; // 𐬵       key <ac07> { [ u10b18,         u10b24 ] }; // 𐬘 𐬤      key <ac08> { [ u10b10,          ue101 ] }; // 𐬐       key <ac09> { [ u10b2e,          ue103 ] }; // 𐬮       key <ac10> { [ u10b3b,         u10b3a ] }; // 𐬻 𐬺      key <ac11> { [ u10b1d                 ] }; // 𐬝       key <ad01> { [ u10b22,         u10b23 ] }; // 𐬢 𐬣      key <ad02> { [ u10b33,         u10b34 ] }; // 𐬳 𐬴      key <ad03> { [ u10b08,         u10b09 ] }; // 𐬈 𐬉      key <ad04> { [ u10b2d,         u10b26 ] }; // 𐬭 𐬦      key <ad05> { [ u10b19,         u10b1a ] }; // 𐬙 𐬚      key <ad06> { [ u10b2b,         u10b2a ] }; // 𐬫 𐬪      key <ad07> { [ u10b0e,         u10b0f ] }; // 𐬎 𐬏      key <ad08> { [ u10b0c,         u10b0d ] }; // 𐬌 𐬍      key <ad09> { [ u10b0a,         u10b0b ] }; // 𐬊 𐬋     key <ad10> { [ u10b1e                 ] }; // 𐬞      key <ad11> { [ u10b06,         u10b07 ] }; // 𐬆 𐬇      key <ad12> { [ u10b02,         u10b03 ] }; // 𐬂 𐬃       key <ae01> { [ u10b78                 ] }; // 𐭸      key <ae02> { [ u10b79                 ] }; // 𐭹      key <ae03> { [ u10b7a                 ] }; // 𐭺      key <ae04> { [ u10b7b                 ] }; // 𐭻      key <ae05> { [ u10b7c                 ] }; // 𐭼      key <ae06> { [ u10b7d                 ] }; // 𐭽      key <ae07> { [ u10b7e                 ] }; // 𐭾      key <ae08> { [ u10b7f                 ] }; // 𐭿       key <bksl> { [ u10b04,         u10b05 ] }; // 𐬄 𐬅      key <lsgt> { [ u10b04,         u10b05 ] }; // 𐬄 𐬅  }; 
  • part of /usr/share/x11/xkb/rules/evdev.xml containing modifications:

    ...    <layout>       <configitem>         <name>ir</name>          <shortdescription>fa</shortdescription>         <description>persian</description>         <languagelist>           <iso639id>per</iso639id>         </languagelist>       </configitem>       <variantlist>         <variant>           <configitem>             <name>pes_keypad</name>             <description>persian (with persian keypad)</description>           </configitem>         </variant>         <variant>           <configitem>             <name>ku</name>              <shortdescription>ku</shortdescription>             <description>kurdish (iran, latin q)</description>             <languagelist>               <iso639id>kur</iso639id>             </languagelist>           </configitem>         </variant>         <variant>           <configitem>             <name>ku_f</name>              <shortdescription>ku</shortdescription>             <description>kurdish (iran, f)</description>             <languagelist>               <iso639id>kur</iso639id>             </languagelist>           </configitem>         </variant>         <variant>           <configitem>             <name>ku_alt</name>              <shortdescription>ku</shortdescription>             <description>kurdish (iran, latin alt-q)</description>             <languagelist>               <iso639id>kur</iso639id>             </languagelist>           </configitem>         </variant>         <variant>           <configitem>             <name>ku_ara</name>              <shortdescription>ku</shortdescription>             <description>kurdish (iran, arabic-latin)</description>             <languagelist>               <iso639id>kur</iso639id>             </languagelist>           </configitem>         </variant>       </variantlist>     </layout>         <layout>       <configitem>         <name>irwinxp</name>          <shortdescription>fa</shortdescription>         <description>persian-winxp</description>         <languagelist>           <iso639id>per</iso639id>         </languagelist>       </configitem>       <variantlist>         <variant>           <configitem>             <name>pes_keypad</name>             <description>persian (with persian keypad)</description>           </configitem>         </variant>         <variant>           <configitem>             <name>ku</name>              <shortdescription>ku</shortdescription>             <description>kurdish (iran, latin q)</description>             <languagelist>               <iso639id>kur</iso639id>             </languagelist>           </configitem>         </variant>         <variant>           <configitem>             <name>ku_f</name>              <shortdescription>ku</shortdescription>             <description>kurdish (iran, f)</description>             <languagelist>               <iso639id>kur</iso639id>             </languagelist>           </configitem>         </variant>         <variant>           <configitem>             <name>ku_alt</name>              <shortdescription>ku</shortdescription>             <description>kurdish (iran, latin alt-q)</description>             <languagelist>               <iso639id>kur</iso639id>             </languagelist>           </configitem>         </variant>         <variant>           <configitem>             <name>ku_ara</name>              <shortdescription>ku</shortdescription>             <description>kurdish (iran, arabic-latin)</description>             <languagelist>               <iso639id>kur</iso639id>             </languagelist>           </configitem>         </variant>       </variantlist>     </layout>      <layout>       <configitem>         <name>iq</name> ... 

but now, these changes new persian-winxp layout not obey irwinxp , irwinxp igored. instead ir controls persian-winxp.

update #2:

unity has problem new layout. new layout icon dark. works well.

dark layout icon

note: use ubuntu 14.04.

creating custom keyboard layout

for example, i'm looking add new modified english (international altgr dead keys) layout swapped r,r & t,t. name xy swapped:rt english (international altgr dead keys).

  1. create new symbols file:

    sudo nano /usr/share/x11/xkb/symbols/xy

    default  partial alphanumeric_keys xkb_symbols "basic" {     name[group1]= "xy swapped:rt english (international altgr dead keys)";     include "us(altgr-intl)"  // custom changes:     key <ad04> { [        t, t,           ediaeresis,   ediaeresis      ] };    key <ad05> { [        r, r,           thorn,        thorn           ] };      include "level3(ralt_switch)" }; 

    include "us(altgr-intl)" means inherits key layout key overridden here.

    you may use keyboard layout editor gui program helps create or edit xkb keyboard layouts. @glutanimate

  2. add new layout declaration /usr/share/x11/xkb/rules/evdev.xml (copy & modify us layout section)

    reference: make new variant keyboard layout available in settings?

    sudo gedit /usr/share/x11/xkb/rules/evdev.xml

    ... <layout>   <configitem>     <name>xy</name>      <shortdescription>en</shortdescription>     <description>xy swapped:rt english (international altgr dead keys)</description>     <languagelist>              <iso639id>eng</iso639id>              <iso639id>fra</iso639id>              <iso639id>ger</iso639id>     </languagelist>   </configitem>   <variantlist>   </variantlist> </layout> ... 
  3. delete xkb cache.

    sudo rm /var/lib/xkb/*.xkm 

    notes:

    to load changes layouts menu close out of gnome-keyboard-preferences , reload, relaunching windows manager should not necessary.

    there change in ubuntu version (13.10) causes keyboard settings cache not refresh after files in "/usr/share/x11/xkb/symbols" directory modified. looks changes don't applied. force cache refreshing 1 should delete *.xkm files "/var/lib/xkb".

    reference: howto: custom keyboard layout definitions

    or

    sudo dpkg-reconfigure xkb-data 

    reference: why did 13.10 break custom keyboard layout?

    custom keyboard layout

reply fix op modifications

  • (update #1 wrong parent layout) have modified xkb_symbols "pes_part_basic" in irwinxp file: that's ok.

    but xkb_symbols "pes" in irwinxp file still:

    include "ir(pes_part_basic)" 

    which should be:

    include "irwinxp(pes_part_basic)" 
  • (update #2 custom icon) if <shortdescription>en</shortdescription> changed <shortdescription>xy</shortdescription>. new layout distinct en , appear xy.

    most there no icon in ubuntu-mono. indicator dynamically generate new 1 may not follow current theme.

    1. copy layout icons dark/light mono themes:

      sudo cp /usr/share/icons/ubuntu-mono-dark/status/22/indicator-keyboard-en.svg /usr/share/icons/ubuntu-mono-dark/status/22/indicator-keyboard-xy.svg sudo cp /usr/share/icons/ubuntu-mono-light/status/22/indicator-keyboard-en.svg /usr/share/icons/ubuntu-mono-light/status/22/indicator-keyboard-xy.svg 
    2. svg files xml. open editing , change text value en xy:

      sudo nano /usr/share/icons/ubuntu-mono-dark/status/22/indicator-keyboard-xy.svg sudo nano /usr/share/icons/ubuntu-mono-light/status/22/indicator-keyboard-xy.svg 

      example:

      <?xml version="1.0" encoding="utf-8" standalone="no"?> <svg width="22" xmlns="http://www.w3.org/2000/svg" version="1.1" height="22">  <defs>   <mask id="m">    <rect y="0" x="0" style="fill:#fff" height="22" width="22"/>    <text y="15.5" x="5" style="font-size:12;font-family:ubuntu;font-weight:500;fill:black">xy</text>   </mask>  </defs>  <rect style="fill:#dfdbd2" mask="url(#m)" rx="2" height="20" width="20" y="1" x="1"/> </svg> 
    3. update theme cache:

      sudo update-icon-caches /usr/share/icons/ubuntu-mono-*/             
    4. logout/login

      new layout custom icon

other helpful references


Comments

Popular posts from this blog

download - Firefox cannot save files (most of the time), how to solve? - Super User

windows - "-2146893807 NTE_NOT_FOUND" when repair certificate store - Super User