Is there a tool to quickly create custom keyboard layouts?

For example to achieve this: https://tex.stackexchange.com/a/86559/1871


Producing Unicode characters in secondary layers, but based on US international (Alt GR-dead keys)

This is mainly to type math in using Unicode, but keeping the default layer to be US international.

Maybe there is one prepared already that is pretty general, if so then how to install it?

This question is not about generating short-cuts in a particular application but to change the system's keyboard layout.


4 Answers 4


I think this tool might work for you although I've never used it. keyboardlayouteditor

If it doesn't work then with a little patience you can create a custom keyboard layout by yourself.

I know it's not a quick way to do it but by doing it this way you will learn something.

If you decide to do it by yourself then the only thing you need to do is edit a file located in /usr/share/x11/xkb/symbols.

Inside the folder "symbols" you will find all the keyboard layout files.

Backup the file you want to use, in your case the "us" file.

To backup the file open a terminal and type:

cp /usr/share/X11/xkb/symbols/us /usr/share/X11/xkb/symbols/us_backup

Now open the "us" file:

sudo gedit /usr/share/X11/xkb/symbols/us

You will see something like this:

// Alphanumeric section
key <TLDE> {    [     grave,    asciitilde  ]   };
key <AE01> {    [     1,    exclam      ]   };
key <AE02> {    [     2,    at      ]   };
key <AE03> {    [     3,    numbersign  ]   };
key <AE04> {    [     4,    dollar      ]   };
key <AE05> {    [     5,    percent     ]   };
key <AE06> {    [     6,    asciicircum ]   };
key <AE07> {    [     7,    ampersand   ]   };
key <AE08> {    [     8,    asterisk    ]   };
key <AE09> {    [     9,    parenleft   ]   };
key <AE10> {    [     0,    parenright  ]   };
key <AE11> {    [     minus,    underscore  ]   };
key <AE12> {    [     equal,    plus        ]   };

The key <xxxx> entries are the name of the keys and the {[]}; entries are the symbols

The image below will show you the key codes:

enter image description here

Now to create your custom keyboard layout you need to replace the contents of {[]}; with the symbol names you want.

For example in order to replace the exclamation mark with the dollar symbol change the following line

key <AE01> {    [     1,    exclam      ]   };

to this:

key <AE01> {    [     1,    dollar      ]   };

After you finish editing your custom keyboard save the file and restart your computer.

In case you want to go back to your original "us" keyboard layout open a terminal and type the following:

sudo cp /usr/share/X11/xkb/symbols/us_backup /usr/share/X11/xkb/symbols/us

For further reading:

  • Thanks, I couldn't make KeyboardLayout to work because of a dependency problem with antlr3 (python). The manual way seems to be viable, but I can't find any example were pure unicode characters are included into the layout: this charvolant.org/~doug/xkb/html/… says that a file /usr/X11R6/include/X11/keysymdefh has that info but I can't find it in my system.
    – alfC
    Apr 2, 2013 at 20:38
  • If you can't find keysymdefh open a terminal and type: sudo apt-get install x11proto-core-dev
    – kalpetros
    Apr 2, 2013 at 21:21
  • 1
    Perhaps it is worth mentioning that you can get yourself into a lot of trouble if you simply remap all of your Latin characters/keys as you will no longer be able to type in the command you need in order to get your keyboard back, i.e. replacing the letter c with dollar will leave you unable to type in cp. Jun 2, 2017 at 19:17
  • this tool is unfortunately abandonware and depends on outdated software, but the info about manual editing and the keyboard picture are super useful and still relevant, thank you Aug 15, 2018 at 7:15
  • I don't like the "restart" part, it makes experimentation and testing soooo long. I tried to add new file and write new layout but indeed it does not appear when I press "add layout" in GUI (and after restart too...). Is there any way I would call it "to update layout cache" w/out restart? Oct 12, 2021 at 2:26

Recently looking at packages I found mathwriter input.

This, apparently in Gnome3, allows the input of mathematical characters as if it were a special language. This allows to enter symbols by typing the name of the symbol, in the screen a menu appears with options and hitting space allow to choose a match.

Relevant links:






I was also personally interested in being able to do this, I made a python program to do it.

Get it here: https://github.com/cuppajoeman/x11-keyboard-layout-generator

To sum it up, you can create custom layouts like this


And it generates a custom layout file which you just have to move to /usr/share/X11/xkb/symbols.

Before you enable your new layout make sure you have set up some shortcuts to switch between them, for example I am using xfce,so I have:

enter image description here

Now we can switch between the math and standard layout easily.

  • Excellent, this is what I have been looking for. The format you show in the txt file should be the standard layout format.
    – alfC
    Oct 24, 2021 at 3:39
  • Great, I created a git repo for it so that improvements can be added. If this answers your question please mark the answer as accepted. Oct 25, 2021 at 15:12

This is not an answer to my own question but a much less invasive alternative that consists in configuring gedit for the purpose of typing unicode/special characters.

After trying some of the proposed solutions, I realized that changing the keyboard layout is an overkill. After all, I needed it only to code (mainly "string"s with unicode and math in LaTeX). So I decided that for my purpose it was better to somehow make my editor able to convert writen words into unicode characters.

My editor is gedit, which has a standard plugin called Snippets. I realized that if I put the special characters in ~/.config/gedit/snippets/global.xml I would be able to type them in any text file.

I made a program that reads a table of unicode characters and a their common names and builds the snippets file. In this way I type the name of character, like _alpha and press TAB and α appears. There are no key combiations or keyboard layers to remember.

After the process my ~/.config/gedit/snippets/global.xml file looks like this. Don't forget to activate the Snippet plugin.

<?xml version='1.0' encoding='utf-8'?>
    <description>New snippet</description>


  1. The idea is taken from here http://ubuntuforums.org/showthread.php?t=1892012 , with the addition that I wrote a program to massively generate the file from a table.
  2. Why the underscore (e.g. _pi)? This is because otherwise many snippets will conflict with the autocompletion feature. For example pi+TAB will not produce π but it will produce picture if this word is mentioned in the document.
  3. Additional characters can be added manually by copying and pasting from the Gnome Character Map program.
  4. To activate the Snippets plugin, first install the gedit plugins package. Then go to Preferences->Plugin->click on Snippets. Then, from the Tools->Manage Snippets... menu, verify that the entries are avialable in the Global group (at the top).

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.