Linux - GeneralThis Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
Hi all, I'm trying to write a new keyboard layout. I'm testing using Debian Squeeze and Kubuntu 11.04, both with KDE. It is important to solve this issue with a keyboard layout as opposed to playing with xmodmap or scancodes and keycodes because I need to leave other keyboard layouts intact and usable. For the time being the new layout is called Noah, implemented as a variant of US English. If this is done more easily by making whole new layout that is not a variant of another then I am willing to go that route.
First off, I am trying to move the Caps Lock key to the current location of the "B" Key. This is my code (the unshown parts of the files have not been touched):
The problem is that this configuration is also affecting the US English layout. When I press "B" the keyboard gives a B _and_ a Caps Lock! So typing I get output like this: "keybOARD". How do I restrict the B key to being Caps Lock only in the Noah layout?
The file /usr/share/X11/xkb/symbols/pc will affect everything, because it is included when compiling all layouts. Leave it to show
modifier_map Lock { Caps_Lock, ISO_Lock };
The key <AB05> will be translated to Caps_Lock by
key <AB05> { [ Backspace, Caps_Lock ] };
All the line in the other file does is to define what Caps_Lock does.
Thanks, David. However, I need to place the "A" key in Noah where the current Caps Lock is, so how can I make the Lock key stop being Caps_Lock when the Noah layout is in use?
As it stands, when I press "A" in the Noah layout it activates the letter "A" _and_ Caps_Lock. Noah "A" is on the QWERTY Caps_Lock key.
The problem here is that <CAPS> is being defined as Caps_Lock by the file …/symbols/pc and also by …/symbols/capslock.
You need to start again with a different approach by editing
/usr/share/X11/xkb/keycodes/evdev
Replace
<CAPS> = 66;
<AB05> = 56;
with
<AC00> = 66;
<CAPS> = 56;
Then all the references to <CAPS> in the original symbols files can be left alone and you will only need to set
key <AC00> { [ a, A ] };
I didn't realise that you were still using the standard layout as well. In that case you will have to keep the evdev file untouched and create a separate symbols file noah. You can incorporate the contents of the pc and capslock files into that, replacing all references to CAPS with AB05.
If that doesn't work, then something will have been calling the pc or capslock files. The command
setxkbmap -print
will show all the material used to create the drivers, so you can check the types and compat files listed, and the ones they call.
Your keyboard installer will probably list available keyboards by language and country, so "noah" will not appear. You can add it manually: on my Fedora computer it's in
~/.gconf/desktop/gnome/peripherals/keyboard/kbd/%gconf.xml
where I have the special keyboard astro enabled:
<entry name="layouts" mtime="1298041593" type="list" ltype="string">
<li type="string">
<stringvalue>gb</stringvalue>
</li>
<li type="string">
<stringvalue>gr</stringvalue>
</li>
<li type="string">
<stringvalue>astro</stringvalue>
</li>
</entry>
Last edited by DavidMcCann; 05-11-2011 at 10:43 AM.
Thanks, David, I just spend a few hours tracking things down through "setxkbmap -print". That was a great tip, I cannot thank you enough!
It seems that I could simply reassign keycodes from aliases in /usr/share/X11/xkb/keycodes/evdev like you suggested earlier, but instead of saving them to that file I would save them to a new file, say, /usr/share/X11/xkb/keycodes/evdev-noah. But how do I call that file from the Noah layout? What does the word "evdev" stand for, this might be hint!
I'm not really sure how things get called, and so I'm stuck. If I create a new layout (not a variant as I have been doing) then I make a new file /usr/share/X11/xkb/symbols/noah using /usr/share/X11/xkb/symbols/us as a template:
Here I'm simply swapping Caps_Lock and "B". What do the declarations "partial" "alphanumeric_keys" "modifier_keys" actually do? How do I call /usr/share/X11/xkb/keycodes/evdev-noah instead of having it call the regular evdev file? What _is_ the airspeed velocity of an unladen swallow?
There are tons of resources online for creating custom layouts, but nothing addresses the modifier keys or Caps. I'm pretty certain if we can swap Caps_Lock and B then I can figure the rest out. Your help is cordially appreciated.
I think I've reached my limits here too! On my keyboard, the old Caps is now Third level shift, old Scroll lock is Group shift, and old Pause is Caps, but this applied to all my keyboard drivers, so I don't have your problem.
The markup in these tables is very obscure. Sections can include references to modifiers without being marked as doing so (and vice versa!) and "partial" is a bit of a mystery too.
The whole process starts when the computer finds a PC (as opposed to Mac or Sun) keyboard and takes evdev for the list of keycodes (unless the distro prefers xfree86). In other words, by the time you log in and it sees what drivers you want, it's too late to change. That's why you can only have one version of evdev.
I think I've reached my limits here too! On my keyboard, the old Caps is now Third level shift, old Scroll lock is Group shift, and old Pause is Caps, but this applied to all my keyboard drivers, so I don't have your problem.
Nice! I also intend to move Caps off to the scroll lock or pause position in the end on this layout. We are similarly fastidious apparently.
Quote:
The markup in these tables is very obscure. Sections can include references to modifiers without being marked as doing so (and vice versa!)
Really?!? That seems to be my issue, as even right there in the stock us(basic) layout there are no include statements. I assumed that the "partial" bit means that it will include something marked as filling in for partial, and maybe the alphanumeric_keys and modifier_keys do something similar. I just don't know, and I don't see it documented anywhere.
Quote:
and "partial" is a bit of a mystery too.
Yes.
Quote:
The whole process starts when the computer finds a PC (as opposed to Mac or Sun) keyboard and takes evdev for the list of keycodes (unless the distro prefers xfree86). In other words, by the time you log in and it sees what drivers you want, it's too late to change. That's why you can only have one version of evdev.
Ah, I see. Thanks. I wonder if any of the CJK or other Asian language keyboards have varied modifier keys, I'll look around and hopefully find something. I'll update the thread if so.
Thanks!
Last edited by dotancohen; 05-14-2011 at 08:43 AM.
10 years later is a long time. However, when looking for any solution for the puzzle of trying to map Caps Lock to a normal key, this discussion was the only guiding light I've found. And what a help it was! So I want to thank both dotancohen and DavidMcCann for their help.
Since what I wanted was to make the Caps key to behave as a level 1 key, DavidMcCann showed me the way in this thread's #4 post. It's as simple as he describes there. You just assign the Caps keycode to a new label (AC00, for example, as he suggested), and change the CAPS keycode to another key, existing or not.
In my case, I pointed the CAPS label to the keycode of a special key I never use on my keyboard. I then created that new AC00 label with the Caps key actual keycode. Then, on my layout file, I defined what characters I wanted printed upon using that AC00 key. Then I saved the file, restarted my X session and, voilá, the magic happened.
So if anyone is looking for something similar, you have to look no further than to this thread. And if both participants are still out there and come across my post, thank you so much for your help. It's exchanges like this that make the internet such a wonderful tool.
Thank you! It's always nice to think that old posts are still doing their job. That's what makes a forum a great place, as opposed to something like a mailing list or (worse) reddit.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.