You are not logged in.

#1 2014-12-14 18:34:42

SteveSapolsky
Member
Registered: 2014-08-09
Posts: 16

[S] How to load another keymap in initramfs with busybox (loadkmap?)?

Loading programmers dvorak in initramfs with busybox.
Solution:

Download the keyboard map. Other keyboard maps you can usually find in "/usr/share/kbd/keymaps/"

wget https://raw.githubusercontent.com/jiangmiao/dvp/master/dvp.map

Now convert that map to the binary format that can be used with `loadkmap`. Make sure you run it with privileges, otherwise you'll get the "Couldn't get a file descriptor referring to the console" error

 sudo loadkeys -b dvp.map > dvp.bmap 

Now you can load that map in initramfs using `loadkmap`. I have a custom initramfs and init and here is the excerpt from it

#!/usr/bin/ash
echo "Starting the init script"
#mount things needed by this script
mount -t proc proc /proc
mount -t sysfs sysfs /sys
# and so on

echo "creating the symlinks to busybox"
/bin/busybox --install -s
echo "loading programmers dvorak"
loadkmap < dvp.bmap
Problem

I have a custom initramfs with Busybox in it. I want to load another keymap in there. Busybox has `loadkmap` utility, unfortunately it expects a binary file, so .map files don't fit in there. The goal is to load programmer's dvorak in busybox, but the problem is generic, because any ANSI .map format will not work with `loadkmap`.

The map for dvp is here: https://github.com/jiangmiao/dvp
Here it was talked about, but unfortunately the patch link is dead: http://mstempin.free.fr/index.php?2005/ … ry-keymaps

How to load a keymap in initramfs with busybox?

FTR, here is the quote from that blog post

Unfortunately, This is not a trivial task in Busybox, as it uses a special binary keymap file format for specifying the keymap to use.

The standard Linux way of handling keymaps is using the kbd utility package. This package contains most of the worldwide keyboard definitions in a keymap format. The two most usefull commands are the loadkeys and dumpkeys, which respectively loads an ASCII keymap file into the kernel's internal translation table and dumps this table to the standard output.

Unfortunately, the keymaps file format (see Linux manual (5) for keymaps) is difficult to parse ,as it requires a full lex/yacc parser to handle it :-(.

However, such a parser is included into loadkeys... And this utility also provides a -m option that generates a C-style output of the file...

After studying Busybox's binary keymap format in details, it appears to be no more than just a file dump of all key translation tables for each state (ie. plain, shifted, controlled, etc.), preceeded by a binary map of translation tables.

So, I decided to write a patch to the kbd package to add a -b option that provides a binary keymap dump capability to loadkeys. Here it is!

Last edited by SteveSapolsky (2014-12-19 12:39:13)

Offline

#2 2014-12-14 19:03:41

progandy
Member
Registered: 2012-05-17
Posts: 5,230

Re: [S] How to load another keymap in initramfs with busybox (loadkmap?)?

In archlinux loadkeys from core/kbd should allow you to generate a binary keymap.

loadkeys -b /your/key.map > key.bmap

| alias CUTF='LANG=en_XX.UTF-8@POSIX ' |

Offline

#3 2014-12-19 12:29:19

SteveSapolsky
Member
Registered: 2014-08-09
Posts: 16

Re: [S] How to load another keymap in initramfs with busybox (loadkmap?)?

progandy wrote:

In archlinux loadkeys from core/kbd should allow you to generate a binary keymap.

loadkeys -b /your/key.map > key.bmap

Thank you. I updated my post and added the solution.

Offline

Board footer

Powered by FluxBB