**********UPDATED May 2010**********
This HowTo is for those of you who are not satisfied with the layout of your keyboard, like myself.
You can have several reasons to do this (eg. for the sake of the experience, for achieving a more ergonomical typing experience, etc). I have done this for the sake of ergonomy. I type a lot (professionally) and I use my computer most of the time (99%). My keyboard is now non-standard, but that's not a problem, since I'm much more productive this way and I STILL know how to use a normal keyboard.
1. The Basics
You don't have to mess with many things. Just edit one file. But to achieve your goal, you have to understand what's in it.
The file is located at:
/usr/share/X11/xkb/symbols/
This is where the different language keyboard layout files are. I use pt and I'll use that as an example. First, backup the file you want to edit so you can put things back normal again if not satisfied. For that do:
just change pt for your selected keyboard.Code:cp /usr/share/X11/xkb/symbols/pt /usr/share/X11/xkb/symbols/pt_backup
now open the file:
You'll see something like this (it's not the complete file, but just a part of it):Code:sudo gedit /usr/share/X11/xkb/symbols/ptkey <AE01> { [ 1, copyright, registered, trademark ] };The entries with key <xxxx> are the name of the keys (based on xkb keycodes*) and their resulting symbols*. There are four symbols you can get when pressing a given key: normal (no modifier key), with Shift key modifier, with Alt Gr key modifier and with Alt Gr + Shift key modifiers.
key <AE03> { [ 3, numbersign, section, paragraph ] };
key <AE04> { [ 4, EuroSign, dollar, sterling ] };
key <AE11> { [ masculine, ordfeminine, dead_circumflex, dead_caron ] };
key <AE12> { [apostrophe, asterisk, plus, dead_abovering ] };
key <AD11> { [dead_acute, dead_grave, dead_diaeresis, dead_macron ] };
key <AD12> { [question, exclam, questiondown, slash ] };
key <AC10> { [ ccedilla, Ccedilla, dead_acute, dead_doubleacute ] };
key <AC11> { [dead_tilde, dead_circumflex, dead_diaeresis, dead_breve] };
key <TLDE> { [ backslash, bar, notsign, notsign ] };
key <BKSL> { [question, exclam, questiondown, slash ] };
Let's take a look at a particular example. Where is located the key <AE12>? You can take a look at following image:
or you can understand the logic behind it. The key <AE12> is located is an Alphanumeric character, located at the row E at the column 12. You can understand the rows and columns layout looking at the picture below:
The other keys, like Control, Alt, and so on, have particular keycodes names. Consult the list of available keycodes to know the key you want.
2. The Actual ConfigurationExample:
- Look at you keyboard and have a thought on what keys you like to change.
- Go to your opened language file (pt in my case).
- Edit the entries accordingly to your needs.
I wanted to change the dead accent and the dead tilde location** as I find them rather unergonomically on the pt keyboard. As such, I edited the file and exchanged the places of the symbols entries for those keys:
key <AD11> { [ plus, asterisk, dead_diaeresis, dead_abovering ] };
key <AD12> { [dead_acute, dead_grave, dead_tilde, dead_macron ] };
and:
key <AC10> { [ ccedilla, Ccedilla, dead_acute, dead_doubleacute ] };
key <AC11> { [ masculine, ordfeminine, dead_circumflex, dead_caron ] };
to become:
key <AD11> { [dead_acute, dead_grave, dead_tilde, dead_macron ] };
key <AD12> { [ plus, asterisk, dead_diaeresis, dead_abovering ] };
and:
key <AC10> { [ masculine, ordfeminine, dead_circumflex, dead_caron ] };
key <AC11> { [ ccedilla, Ccedilla, dead_acute, dead_doubleacute ] };
It's easy as this. Remember that you can even put different symbols that weren't there in the first place, like making your backspace key type an ® you you want. It's all up to you.
You thenBefore you do this, take a look at the next section, 3. Hints.
- save the file
- restart your X session (logout and press ctrl+alt+backspace
3. Hints
1. Since to try the new keyboard layout you'll need to restart your X session, you can use this trick to test it without abandoning your current session. After saving the file, you open a terminal and type:
This will open a new screen with a terminal on it. Type around on that terminal to see if you got the expected results. To end that session, just press ctrl+alt+backspace and you'll get back to your current session again. Do this as many times as you like it until you have achived your final keyboard layout.Code:sudo xinit -- :2
2. If you really like your new keyboard layout (like I do) and want it to survice future installations, you just have to put your keyboard layout file on a archive folder on you home (supposing you have a different partition for you /home) and then link the file to the actual file on /etc.
example:
You create a archive folder on your /home on the location:
/home/archive/keyboard/layout
and put there your layout file my_layout.
Then you just have to backup your language layout file (probably you just did on the beginning of the HowTo) and then link your layout file to the actual language layout file, like this:
Just adjust the folders and file names to your needs. Your layout will be preserved even if newly install your system. You can repeat the link step after an installation to get you layout working again.Code:sudo ln -sf /home/archive/keyboard/layout/my_layout /usr/share/X11/xkb/symbols/pt
4. Documentation
You can find further information about this topic on the following sites:
- An unreliable guide to xkb configuration (don't let the name fool you)
- How to configure xkb
5. Reverting to the Original Layout
1. Ok, you are not satisfied with the experience, you grow tired of your layout and want your old keyboard back. No problem, since you made a backup at the beginning of the HowTo. To revert to your original layout, you just have to do:
After this, you just have to restart your X session and next time you login you'll have the normal layout again. Please note that the pt must be changed to your own language keyboard layout.Code:sudo cp /usr/share/X11/xkb/symbols/pt_backup /usr/share/X11/xkb/symbols/pt
2. You thought you were Dvorak himself and changed your complete keyboard layout. You were prepared to chalenge yourself for the hard work of learning a complete new set of keys and then you fail miserably in doing so, finding yourself stuck with a untypeable keyboard where it's a headache to find the keys. Don't stress. You have the layout backup. "But I can't type the commands!".
No problem. Press ctrl+alt+F1 and you're on the console. Login and type:
After this, press ctrl+alt+F7 to get back to your X session again.Code:sudo cp /usr/share/X11/xkb/symbols/pt_backup /usr/share/X11/xkb/symbols/pt
Restart your session and you'll have your normal keyboard back again.
*An extensive list of keycodes and symbols available can be found on the files I attached for your convinience.
**In actuality, I changed the location of all dead accents and the ? and the ! punctuation marks. I don't know who designated those keys on the Portuguese keyboard, but certainly it was not a professional typist versed in this language. It's not my point to discuss this here, so I just simplified the example.
Bookmarks