[SOLVED] How to match X keyboard layout with the the kernel keyboard map?
SlackwareThis Forum is for the discussion of Slackware Linux.
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.
How to match X keyboard layout with the the kernel keyboard map?
As a reminder:
(1) the kernel keymap for the console can be chosen (either during installation or later) among those available in directories:
/usr/share/kbd/keymaps/i386/{azerty,colemak,dvorak,fgGlod,olpc,qwerty,qwertz}
(2) the keyboard layout used under X can be set among those listed under "! layout" in file:
/usr/share/X11/xkb/rules/evdev.lst
I would like that during Slackware configuration post-installation, whenever possible a user who has chosen a given kernel keymap be offered to set a matching X keyboard layout (if it exists and the kbd and xorg-server packages have been installed, of course). In other words in that case copy /usr/share/X11/xorg.conf.d/90-keyboard-layout.conf to /etc/X11/xorg.conf.d and replace in it 'Option "XkbLayout" "us"' by whatever appropriate (and possibly set the "XkbVariant" option as well, picking one under "! variant" in evdev.lst).
It's easy in my case as I use "fr.map" and has just to replace "us" by "fr" in the X configuration file but that is very often *a lot* more tricky.
Thanks in advance for any clue, idea, experience, information about how it is done by other distributions or existing software, etc.
PS Debian's console-setup source package includes two interesting scripts from Anton Zinoviev, namely ckbcomp-mini (shell) and ckb-comp (perl). I'll simply quote their manual page below:
Code:
NAME
ckbcomp - compile a XKB keyboard description to a keymap suitable for
loadkeys or kbdcontrol
SYNOPSIS
ckbcomp [OPTION...] [XKBLAYOUT [XKBVARIANT [XKBOPTIONS]...]]
DESCRIPTION
The ckbcomp keymap compiler converts a description of an XKB keyboard
layout into a console keymap that can be read directly by loadkeys(1)
or kbdcontrol(1).
That looks very nice, indeed. The only problem being that I want to make the reverse conversion
Last edited by Didier Spaier; 03-23-2013 at 03:53 PM.
Reason: PS added
setxkbmap maps the keyboard to use the layout determined by the options specified in the command (or in the config files if no option is given), IOW put in effect an existing XKB keyboard description.
What I want to do is compute an XKB keyboard description matching a given kernel keymap.
Let's take an example.
Assuming that I have chosen the kernel keymap pt-latin9.map, how to set appropriately XkbLayout, XkbVariant, ... so that pressing a given key output the same character on an X terminal as it does on the console?
Last edited by Didier Spaier; 03-23-2013 at 07:15 AM.
Debian uses its own software to setup console (console-setup). I know that Debian lets you write xkboptions on /etc/default/keyboard. But I didn't investigate in which way debian do that trick.
Now in the opposite way. I have a personal es.map for Slackware just to add euro sing and slight modifications and another highly modified for a machitosh keyboard, but I would not try to write a "translator" to xkboptions for that .
I couldn't make some modifications to the standard keymap using xkboptions. In this cases I must use a Xmodmap file.
Resuming depending on how complex are the modifications you need I think that translating them to xkboptions could be not possible or very tricky. Even doing it manually (I understand you want to automatize).
Well that's what I know. I didn't help too much this time.
Last edited by eloi; 03-23-2013 at 11:13 AM.
Reason: grammar correction
Well, I'm not looking for nor needing something perfect.
If the mapping for [A-7,a-z,0-9], punctuation, and some other characters useful for shell scripting and password typing is correct, that's good enough for me.
Users will still have to make customization in some cases, but at least they won't have to figure out any more "Why the password which works on the console doesn't after startx?"
PS I didn't ask Anton to elaborate his "No", as I tend to simply trust someone able to write a 4728 lines and 147645 characters long perl script to perform the conversion one way who tells me that reverse is not possible
<OT>@BDFL: just in case you didn't know already, Anton is volunteer to make or help making a Slackware package of console-setup (or parts of it which could benefit to Slackware).</OT>
Last edited by Didier Spaier; 03-24-2013 at 06:29 AM.
Reason: PS added
Well, I'm not looking for nor needing something perfect.
If the mapping for [A-7,a-z,0-9], punctuation, and some others useful for shell scripting and password typing is correct, that's good enough for me.
Users will still have to make customization in some cases, but at least they won't have to figure out any more "Why the password which works on the console doesn't after startx?"
That would be the way to go once the system is installed.
But I'm doing that from the installer (near the end of the 'setup' script). So I'll simply propose the user to do for him or her during installation what is suggested in CHANGES_AND_HINTS.TXT: copy /usr/share/X11/xorg.conf.d/90-keyboard-layout.conf to /etc/X11/xorg.conf.d and edit the copy.
I just need to know how to set XkbLayout and XkbVariant options for a given locale (asking the user at this point is not an option I'd consider).
As I don't expect the installer to include more than ~350 locales before end of current year, what Anton suggests (and to which I am ashamed not having thought of myself from the beginning) fits my needs
Last edited by Didier Spaier; 03-24-2013 at 03:01 PM.
Seems to me that one could in the shell, loop the program through all possible translations and have it echo out a translation table similar to the one above. Have it print it out both ways to convert both ways. I just did a similar trick last week to create tables to convert unix permissions from octal-to-human and human-to-octal.
Seems to me that one could in the shell, loop the program through all possible translations and have it echo out a translation table similar to the one above. Have it print it out both ways to convert both ways. I just did a similar trick last week to create tables to convert unix permissions from octal-to-human and human-to-octal.
Maybe... This is not my priority but would you want to try, the source console-setup package for squeeze is here (aforementioned scripts are in /Keyboard).
"All possible" may be a bit tricky to determine though, as maybe not all variants are relevant for all layouts, for instance. That's only a question as my knowledge in this matter would hardly fill a thimble.
Last edited by Didier Spaier; 03-24-2013 at 02:46 PM.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.