LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Slackware
User Name
Password
Slackware This Forum is for the discussion of Slackware Linux.

Notices


Reply
  Search this Thread
Old 03-21-2013, 06:37 PM   #1
Didier Spaier
LQ Addict
 
Registered: Nov 2008
Location: Paris, France
Distribution: Slint64-15.0
Posts: 11,057

Rep: Reputation: Disabled
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
 
Old 03-23-2013, 06:40 AM   #2
eloi
Member
 
Registered: Nov 2010
Posts: 227

Rep: Reputation: 61
Hi Didier,

Perhaps I didn't understand what you want. Do you know setxkbmap command?

Last edited by eloi; 03-23-2013 at 06:46 AM.
 
Old 03-23-2013, 07:13 AM   #3
Didier Spaier
LQ Addict
 
Registered: Nov 2008
Location: Paris, France
Distribution: Slint64-15.0
Posts: 11,057

Original Poster
Rep: Reputation: Disabled
Hi Walter,

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.
 
Old 03-23-2013, 11:09 AM   #4
eloi
Member
 
Registered: Nov 2010
Posts: 227

Rep: Reputation: 61
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
 
Old 03-23-2013, 11:26 AM   #5
Didier Spaier
LQ Addict
 
Registered: Nov 2008
Location: Paris, France
Distribution: Slint64-15.0
Posts: 11,057

Original Poster
Rep: Reputation: Disabled
Thanks anyway. Quizás la próxima vez.
 
Old 03-23-2013, 03:51 PM   #6
Didier Spaier
LQ Addict
 
Registered: Nov 2008
Location: Paris, France
Distribution: Slint64-15.0
Posts: 11,057

Original Poster
Rep: Reputation: Disabled
I sent an email to Anton Zinoviev:
Quote:
My question is: would it be possible to make the reverse conversion, i.e. knowing the kernel keymap, compute a matching XKB kernel description?
His response was fast and clear:
Code:
No.  However you can use an approximate guesswork similar to the one 
used in Debian before console-setup was utilized by the installer:

    case "$console_keymap" in
        be2) XKBLAYOUT="be";;
        bg) XKBLAYOUT="us,bg";;
        br) XKBLAYOUT="us"; XKBVARIANT="intl";;
        br-abnt2) XKBLAYOUT="br"; XKBVARIANT="abnt2";;
        by) XKBLAYOUT="us,by";;
        cf) XKBLAYOUT="ca"; XKBVARIANT="fr";;
        croat) XKBLAYOUT="hr";;
        cz-lat2) XKBLAYOUT="cz";;
        de-latin1-nodeadkeys) XKBLAYOUT="de"; XKBVARIANT="nodeadkeys";;
        de) XKBLAYOUT="de";;
        dvorak) XKBLAYOUT="us"; XKBVARIANT="dvorak";;
        dk) XKBLAYOUT="dk";;
        es) XKBLAYOUT="es";;
        et) XKBLAYOUT="ee";;
        'fi') XKBLAYOUT="fi";;
        fr-latin9) XKBLAYOUT="fr"; XKBVARIANT="latin9";;
        fr_CH) XKBLAYOUT="ch"; XKBVARIANT="fr";;
        fr) XKBLAYOUT="fr";;
        hebrew) XKBLAYOUT="us,il";;
        hu) XKBLAYOUT="hu";;
        gb) XKBLAYOUT="gb";;
        is) XKBLAYOUT="is";;
        it) XKBLAYOUT="it";;
        jp106) XKBLAYOUT="jp"; XKBVARIANT="106";;
        la) XKBLAYOUT="latam";;
        lt) XKBLAYOUT="lt";; 
        lv-latin4) XKBLAYOUT="lv";;
        mac-us-std) XKBLAYOUT="us";;
        mac-de2-ext) XKBLAYOUT="de"; XKBVARIANT="nodeadkeys";;
        mac-fr2-ext) XKBLAYOUT="fr";;
        mac-fr3) XKBLAYOUT="fr";;
        mac-es) XKBLAYOUT="es";;
        ky) XKBLAYOUT="us,kg";;
        mk) XKBLAYOUT="us,mk";;
        nl) XKBLAYOUT="nl";;
        no) XKBLAYOUT="no";;
        pl) XKBLAYOUT="pl";;
        pt) XKBLAYOUT="pt";;
        ro) XKBLAYOUT="ro";;
        ru) XKBLAYOUT="us,ru";;
        se) XKBLAYOUT="se";;
        sg) XKBLAYOUT="ch"; XKBVARIANT="de";;
        sk-qwerty) XKBLAYOUT="sk"; XKBVARIANT="qwerty";;
        slovene) XKBLAYOUT="si";;
        sr-cy) XKBLAYOUT="cs,cs"; XKBVARIANT="latin,basic" ;;
        trf|trfu) XKBLAYOUT="tr"; XKBVARIANT="f";;
        trq|trqu) XKBLAYOUT="tr";;
        ua) XKBLAYOUT="us,ua";;
        uk) XKBLAYOUT="gb";;
        us) XKBLAYOUT="us";;
        *) 
            XKBLAYOUT="us"
        ;;
    esac
I'll do just that (at the end of 'setup' in Slackware's unofficial internationalized installer).

So I mark this thread [solved]. Thanks to all who took the time to read it.

Last edited by Didier Spaier; 03-24-2013 at 02:59 PM.
 
Old 03-24-2013, 04:08 AM   #7
eloi
Member
 
Registered: Nov 2010
Posts: 227

Rep: Reputation: 61
After *trying* it you will find out that my not so clear response was an explanation for the starting Anton's "No".
 
Old 03-24-2013, 04:31 AM   #8
Didier Spaier
LQ Addict
 
Registered: Nov 2008
Location: Paris, France
Distribution: Slint64-15.0
Posts: 11,057

Original Poster
Rep: Reputation: Disabled
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
 
Old 03-24-2013, 05:30 AM   #9
eloi
Member
 
Registered: Nov 2010
Posts: 227

Rep: Reputation: 61
More puzzles?

Quote:
Originally Posted by Didier Spaier View Post
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's why I suggest you setxkbmap.
 
Old 03-24-2013, 05:56 AM   #10
Didier Spaier
LQ Addict
 
Registered: Nov 2008
Location: Paris, France
Distribution: Slint64-15.0
Posts: 11,057

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by eloi View Post
That's why I suggest you setxkbmap.
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.
 
Old 03-24-2013, 01:23 PM   #11
gnashley
Amigo developer
 
Registered: Dec 2003
Location: Germany
Distribution: Slackware
Posts: 4,928

Rep: Reputation: 612Reputation: 612Reputation: 612Reputation: 612Reputation: 612Reputation: 612
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.
 
Old 03-24-2013, 02:40 PM   #12
Didier Spaier
LQ Addict
 
Registered: Nov 2008
Location: Paris, France
Distribution: Slint64-15.0
Posts: 11,057

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by gnashley View Post
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.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
keyboard map Atreo Linux - Newbie 2 12-13-2006 02:44 AM
keyboard map neilcpp Slackware 1 01-16-2006 03:16 PM
Keyboard map Noido Linux - General 10 06-14-2005 02:41 AM
Keyboard Map UltraSoul *BSD 1 02-08-2005 11:21 AM
keyboard map logicport Linux - Software 1 07-26-2004 11:45 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Slackware

All times are GMT -5. The time now is 03:18 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration