Skip to contentSkip to conversation

keyboard layouts

DISCUSSION Carles Pina i Estany 4 participants 6 messages Jan 12, 2010 – Jan 13, 2010

lore
Share & tools
lore
#0 lore raw

Hi,

I'm looking again to the keyboard layouts task.

Plan:
- Use the X11 layouts that usually are in /usr/share/X11/xkb/symbols .
- Create a new module that reads the layout from an environtment variable.

* Approach 1
The module will load the layout from /usr/share/X11/xkb/symbols/XX replacing the array map that currently exists in term/i386/pc/at_keyboard.c

Negative points:
-Grub needs acces to /usr/share/X11/xkb/symbols to load the layout
-xkb files doesn't look specially nice to parse (I think that I prefer the .mo files :-) ). They are text files easy to understand for humans

* Approach 2
Small program (I guess that you prefer C, Python would be nice too) that when Grub is installed would process the /usr/share/X11/xkb/symbols files and generates the files that Grub will read. Code to read this files would be much easier than before.

This way, the layout tables could stay in /boot/grub/layouts . These files would look like keycode - symbol pairs. Everything already in binary, and only for the things that differ from English.

So, if a layout has 40 different keycode-symbol pairs compared with English, this would be 80 bytes per layout. Probably will be more, but it should be of this order of magnitude.

* End of Approach 2

Opinions? What I'm forgetting?

Here appeared some suggestions:
http://www.mail-archive.com/[email protected]/msg08301.html

Like Shift+Caps Lock could write special symbols, or the very advanced (combo, dead-keys) things. I will consider it, now I'm mainly thinking about the basic layout.

Signature · 2 lines
Carles Pina i Estany
	http://pinux.info
#1 lore raw
Quoted 21 lines · Carles Pina i Estany

Plan:
- Use the X11 layouts that usually are in /usr/share/X11/xkb/symbols .
- Create a new module that reads the layout from an environtment variable.

* Approach 1
The module will load the layout from /usr/share/X11/xkb/symbols/XX replacing the array map that currently exists in term/i386/pc/at_keyboard.c

Negative points:
-Grub needs acces to /usr/share/X11/xkb/symbols to load the layout
-xkb files doesn't look specially nice to parse (I think that I prefer the .mo files :-) ). They are text files easy to understand for humans

* Approach 2
Small program (I guess that you prefer C, Python would be nice too) that when Grub is installed would process the /usr/share/X11/xkb/symbols files and generates the files that Grub will read. Code to read this files would be much easier than before.

Quoted 7 lines

This way, the layout tables could stay in /boot/grub/layouts . These files would look like keycode - symbol pairs. Everything already in binary, and only for the things that differ from English.

So, if a layout has 40 different keycode-symbol pairs compared with English, this would be 80 bytes per layout. Probably will be more, but it should be of this order of magnitude.

I can't remember whether I mentioned this before, but have a look at the gfxboot-theme-ubuntu package in Ubuntu, specifically the scrape-console-setup script. It makes use of console-setup to process XKB keymaps into a form that can then be run through loadkeys and reformatted so that gfxboot can use them. A similar approach might be feasible in GRUB.

(console-setup is Debian-specific, but perhaps we could incorporate the relevant bits of it in grub-extras, or do something else creative ...)

Signature · 1 line
Colin Watson                                       [[email protected]]
#2 lore raw

Hi,

Quoted 13 lines · Colin Watson
Quoted 12 lines · Carles Pina i Estany

Plan:

* Approach 2
Small program (I guess that you prefer C, Python would be nice too) that when Grub is installed would process the /usr/share/X11/xkb/symbols files and generates the files that Grub will read. Code to read this files would be much easier than before.

This way, the layout tables could stay in /boot/grub/layouts . These files would look like keycode - symbol pairs. Everything already in binary, and only for the things that differ from English.

Quoted 5 lines
Quoted 3 lines

So, if a layout has 40 different keycode-symbol pairs compared with English, this would be 80 bytes per layout. Probably will be more, but it should be of this order of magnitude.

I can't remember whether I mentioned this before, but have a look at

I haven't read about it previously.

Quoted 5 lines

the gfxboot-theme-ubuntu package in Ubuntu, specifically the scrape-console-setup script. It makes use of console-setup to process XKB keymaps into a form that can then be run through loadkeys and reformatted so that gfxboot can use them. A similar approach might be feasible in GRUB.

Legal question: gfxboot-theme-ubuntu is licensed under GPL 2. I understand that this means that we cannot share code. In the other hand, I think that you are the author, so you could give the copyright of this code to the FSF if needed. Is it possible?

Integration question: some of that code is done using Perl. Actually are quite small scripts (373 lines the longer one). I don't know if we want to add Perl as a Grub dependency :-/, or if it's worth. We can redo the script in C.

Ok, the process of scrape-console-setup (I have not been able to test it yet) is to use ckbcomp to convert from XKB keymaps to the "loadkeys" keymaps, and then does some process on this second keymaps.

My approach was avoiding ckbcomp (actually I didn't know it :-) ). The loadkeys keymaps are easier to parse, so for me looks fine to use. In the other hand adds a new dependency, only for the laziness of processing the XKB layouts.

Can you write in two lines the format of the layout that gfxboot use? (else I will try to generate it soon...)

Thanks,

Signature · 2 lines
Carles Pina i Estany
	http://pinux.info
#3 lore raw
Quoted 11 lines · Carles Pina i Estany
Quoted 5 lines · Colin Watson

the gfxboot-theme-ubuntu package in Ubuntu, specifically the scrape-console-setup script. It makes use of console-setup to process XKB keymaps into a form that can then be run through loadkeys and reformatted so that gfxboot can use them. A similar approach might be feasible in GRUB.

Legal question: gfxboot-theme-ubuntu is licensed under GPL 2. I understand that this means that we cannot share code. In the other hand, I think that you are the author, so you could give the copyright of this code to the FSF if needed. Is it possible?

GPL 2 or later, actually, so we could share it. But yes, I'd be willing to assign for the purposes of a GRUB derivative of scrape-console-setup, if you chose to use that source. I did not write all of gfxboot-theme-ubuntu by any means, but I wrote both the scrape-* scripts there from scratch.

console-setup is also GPL 2 or later, but you'd have to ask Anton Zinoviev if you chose to copy it.

Quoted 4 lines

Integration question: some of that code is done using Perl. Actually are quite small scripts (373 lines the longer one). I don't know if we want to add Perl as a Grub dependency :-/, or if it's worth. We can redo the script in C.

scrape-console-setup is really only incidentally in Perl; it's not that complicated and could be done in any reasonable language. You'd need to rewrite much of it for GRUB's keymaps anyway.

ckbcomp, though, is very complicated and difficult to reimplement. If you were going to reimplement it, then it might be worth looking at something like embedding a partial XKB parser in GRUB after all ...

To my knowledge, there is no serious alternative to XKB as a source of keymaps. The old-style Linux keymaps (console-data et al) are long since moribund, and XKB is what nearly everyone will be using on their running systems anyway so it's good to be consistent with those keymaps as far as possible.

Quoted 3 lines

Ok, the process of scrape-console-setup (I have not been able to test it yet) is to use ckbcomp to convert from XKB keymaps to the "loadkeys" keymaps, and then does some process on this second keymaps.

Yes. The reason is, as you say, that the loadkeys format is a lot closer to what a boot loader tends to want. Processing XKB is fairly hard (although GRUB is more sophisticated than gfxboot, so who knows).

Quoted 2 lines

Can you write in two lines the format of the layout that gfxboot use? (else I will try to generate it soon...)

You can look at gfxboot-theme-ubuntu/keytables.inc for the generated version. It's a series of arrays of [ level1 level2 level3 level4 ] keycodes.

(Not quite two lines but I hope you don't mind ...)

Signature · 1 line
Colin Watson                                       [[email protected]]
#4 lore raw
In reply to Carles Pina i Estany

Hi

Quoted 10 lines · Carles Pina i Estany

Plan:
- Use the X11 layouts that usually are in /usr/share/X11/xkb/symbols .
- Create a new module that reads the layout from an environtment variable.

* Approach 1
The module will load the layout from /usr/share/X11/xkb/symbols/XX replacing the array map that currently exists in term/i386/pc/at_keyboard.c

But where are this X11 keyboard layouts in non linux platform (windows, Mac OSX, etc...) ?

Quoted 7 lines

* Approach 2
Small program (I guess that you prefer C, Python would be nice too) that when Grub is installed would process the /usr/share/X11/xkb/symbols files and generates the files that Grub will read. Code to read this files would be much easier than before.

Same thing.

Regards,
Yves Blusseau

#5 lore raw
Quoted 8 lines · Yves Blusseau

Hi

Quoted 5 lines · Carles Pina i Estany

Plan:
- Use the X11 layouts that usually are in /usr/share/X11/xkb/symbols .
- Create a new module that reads the layout from an environtment variable.

Quoted 8 lines
Quoted 6 lines

* Approach 1
The module will load the layout from /usr/share/X11/xkb/symbols/XX replacing the array map that currently exists in term/i386/pc/at_keyboard.c

But where are this X11 keyboard layouts in non linux platform (windows, Mac OSX, etc...) ?

X11 is freely distribuable so there is no reason not to rely on them. Even if some platforms use other formats (XML-like OSX' .keylayout, or "ultra-portable" and "readable" windows' .dll) there shouldn't be any problem installing XKB layouts as optional GRUB2 prerequisite. On another note we support windows and OSX as long as they don't force us taking bad decisions or slow thedeveloppement

Quoted 19 lines
Quoted 7 lines

* Approach 2
Small program (I guess that you prefer C, Python would be nice too) that when Grub is installed would process the /usr/share/X11/xkb/symbols files and generates the files that Grub will read. Code to read this files would be much easier than before.

Same thing.

Regards,
Yves Blusseau

------------------------------------------------------------------------

_______________________________________________
Grub-devel mailing list
[email protected]
http://lists.gnu.org/mailman/listinfo/grub-devel

Signature · 2 lines
Regards
Vladimir 'φ-coder/phcoder' Serbinenko