How to edit Keyboard Layouts?

Booting, installing, newbie
Post Reply
Message
Author
adXok
Posts: 68
Joined: Fri 12 Mar 2010, 12:08

How to edit Keyboard Layouts?

#1 Post by adXok »

Hi,
I tried to edit my 'bg' keyboard layout. I found it in usr, x11... kbd etc. and I edited it with the text editor. Saved it and tried to starti it once again with the Keyboard wizard but it still loads the first of the layouts in the 'bg' file.

Questions:

1. Is there anothe rplace where I am supposed to edit the new entry in the file, though I just edit the keys tags <xxx> symbols in the [...];
2. If a layout consist of more than one layout how am i supposed to switch between those layouts? (Yes, I know how to switch between two language layouts but do not know how to switch between two or more variations of one layout)

Hope I expressed my self clear enough for you to understand the problem.
Lucid Puppy 5.2.5 here.

User avatar
Dougal
Posts: 2502
Joined: Wed 19 Oct 2005, 13:06
Location: Hell more grotesque than any medieval woodcut

#2 Post by Dougal »

Are you interesting in changing it for the console only? The X keyboard layouts are in /etc/X11/xkb/symbols...
What's the ugliest part of your body?
Some say your nose
Some say your toes
But I think it's your mind

adXok
Posts: 68
Joined: Fri 12 Mar 2010, 12:08

#3 Post by adXok »

I want to change certain keyboard layout entries for example

Code: Select all

key <TLDE> {   [ Cyrillic_che,      Cyrillic_CHE        ]    };
  key <AE01> {   [ 1,                 exclam              ]    };
  key <AE02> {   [ 2,                 at                  ]    };
  key <AE03> {   [ 3,                 numbersign          ]    };
  key <AE04> {   [ 4,                 dollar              ]    };
and so on... changed {

Code: Select all

<TLDE> instead of [hardsing         HARDSIGN] }; 
to what you see above.

After being saved and reloaded by the keyboard Wizard it just persist at its original (non-edited) state. Why? Must be reading it from any other place which I am not aware of.

User avatar
Luluc
Posts: 200
Joined: Wed 16 Mar 2011, 07:10

Re: How to edit Keyboard Layouts?

#4 Post by Luluc »

adXok wrote:1. Is there anothe rplace where I am supposed to edit the new entry in the file, though I just edit the keys tags <xxx> symbols in the [...];
2. If a layout consist of more than one layout how am i supposed to switch between those layouts? (Yes, I know how to switch between two language layouts but do not know how to switch between two or more variations of one layout)
1. Don't waste your time messing up with system-level keyboard layout files. Instead, create a file named .Xmodmap in your home directory, i.e. /root/.Xmodmap.

Search Xmodmap on Google, you should have no problem finding thorough explanations on how to use it. Come back here and cry for help if needed.

2. I don't know. I would like to know, too.

User avatar
Dougal
Posts: 2502
Joined: Wed 19 Oct 2005, 13:06
Location: Hell more grotesque than any medieval woodcut

#5 Post by Dougal »

adXok wrote:After being saved and reloaded by the keyboard Wizard it just persist at its original (non-edited) state. Why? Must be reading it from any other place which I am not aware of.
What do you mean by "saved and reloaded by the keyboard Wizard"? The simplest way would be to restart X.

In any case, such a modification is best done like Luluc mentioned, via Xmodmap.
What's the ugliest part of your body?
Some say your nose
Some say your toes
But I think it's your mind

adXok
Posts: 68
Joined: Fri 12 Mar 2010, 12:08

#6 Post by adXok »

Thank you guys. I will try that Xmodmap thing

By saving it I meant in the text editor. later I restart X and no success - it still uses the old variant of the layout. I always do that change with ubuntu and seems I have a success. Recently I haven't tried that on the news distros... dont know if it will still be working.

Though I would certainly would like to know how to change between Layout variants of one language (for example QWERTY or Dvorak, Phonetic or Standart in Cyrillic and so on).

:)

User avatar
Luluc
Posts: 200
Joined: Wed 16 Mar 2011, 07:10

#7 Post by Luluc »

I hacked my keyboard layouts one Ubuntu version ago. It worked, but it was complicated like hell. Then I upgraded my new Ubuntu installation and the hacks didn't work anymore. I gave up, very frustrated for not having the keyboard layout I had grown myself accustomed to.

Then I remembered Xmodmap. It is not just easier, it's portable. I am using the exact same .Xmodmap file on Puppy and Ubuntu, it works fine. Also I no longer have problems with KDE forgetting my Esc/Tab swap choice. That choice is a lot more stable on Xmodmap.

adXok
Posts: 68
Joined: Fri 12 Mar 2010, 12:08

#8 Post by adXok »

So are you telling me that after Xmodmap is properly edited and saved, placed (where?) it will allow me to change not only my keyboard layout switching and their keycodes but also to allo me to switch between two or more different versions of a language layout (for example Int. and Dvorak)?

If not, then it is not worth it do the xmodmapd edit operation.

User avatar
Luluc
Posts: 200
Joined: Wed 16 Mar 2011, 07:10

#9 Post by Luluc »

Yes, I think I made a mistake. Although it is quite possible to remap an entire keyboard/model layout with xmodmap, it is not the most practical way. You would have to remap each key individually. Just once, in a script, but that is still too troublesome. You should use setxkbmap instead. Look at the script I use to switch between US Intl and Brazilian ABNT2:

Code: Select all

#!/bin/sh

if 	[[ `setxkbmap -print | grep -i abnt2` ]]; then
	setxkbmap -model pc104 -layout us -variant intl
	xmodmap ~/.Xmodmap
else
	setxkbmap -model abnt2 -layout br -variant abnt2
	xmodmap ~/.Xmodmap
fi
Here is an explanation for those not familiar with shell scripting:
* Feed the output of 'setxkbmap -print' into grep.
IF
* If the string "abnt2" is found (grep returns "0" which mean success), that's because I am already using the ABNT2 layout, in that case switch to the US Intl model/layout.
* Right after that, run my .Xmodmap file.
ELSE
* If the string "abnt2" is NOT found (grep returns "1" which mean failure/not found), that's because I am NOT using the ABNT2 layout, in that case please switch to the ABNT2 model/layout.
* Right after that, run my .Xmodmap file.

I have no visual output, but it works just fine.

Then I have that script run by a keyboard shortcut on Openbox. Voilá, I have a keyboard shortcut that switches my keyboard layout.

Now, you will have to research a little to know what strings you should use for the models/layouts you want.

I hope this helps.

adXok
Posts: 68
Joined: Fri 12 Mar 2010, 12:08

#10 Post by adXok »

Sorry, I am not a soft-dev. I cannot understand what you are reading.
Why, why it has to be so complicated...

In windows all that is done with a simple program (layout editor) and installer (setup.exe exported form the layout editor program).

It used to be easy in the old versions of Mint, Ubuntu and even Puppy.
I still got my 4.3.1 and there a simple edit in kbd works like a charm.

Excuse me but a keyboard?! The most critical hardware component to "comunicate" with the computer! I do not get it.

User avatar
Luluc
Posts: 200
Joined: Wed 16 Mar 2011, 07:10

#11 Post by Luluc »

Welcome to Linux.

shungabubus
Posts: 3
Joined: Wed 22 Jun 2011, 18:02

Come on

#12 Post by shungabubus »

Luluc don't be jerk.
AdXok, use xkbconfigmanager. This is a graphical application where with 3 clicks you can arrange your keyboard.

Post Reply