Philipp's picture

Hi. How can I define, which keyboard layout is used right after installation of my custom appliance?

Especially when entering passwords, a wrong keyboard layout can be annoying.


Jeremy Davis's picture

How about an an inithook?

If you are familiar with python, there are a few confconsole plugins, in the Region Config section that might give you some hints of the commands required?! In particular the Keyboard one (but the locale and timezone one's might also be of interest?).

As far as creating the inithook, it's probably best to have a read of the docs and a bit of a play. Then if you have any further questions, please ask. In case it's not already obvious, the inithook(s) go into the overlay (overlay/usr/lib/inithooks/...).

Also, if it's quite likely that your users will want German language, then you might wish to allow locale configuration on firstboot too (again check the locale confconsole plugin for hints)? You may also wish to configure the local-purge package to also keep German system docs (currently it purges all non US English docs at build time to minimise ISO size).

Philipp's picture

I already have some custom inithooks ;-)

The "" within the confconsole plugin executes "dpkg-reconfigure %s keyboard-configuration' % flag" and "service keyboard-setup restart", but the reconfiguration-dialog will not be executed.

When running "dpkg-reconfigure keyboard-configuration", I can setup the keyboard, but it does not have any effect. Even after reboot, the console keyboard layout is still english.

Jeremy Davis's picture

That's not good!

I wonder when that stopped working?! FWIW, the code for that originally came from a user (who confirmed it worked for them; with others also confirming it worked round the same time). All the core devs only have access to US International keyboards, so we've never actually directly tested it.

So whilst it's a pain that it doesn't work, it's actually awesome that we know it's not working! (I've opened a new issue for this).

Hopefully though, with a bit of assistance from me, we can get it working and update the code!

So doing a bit of googling, I've found a few bits and pieces, but I'm not really sure which might be the missing piece of the puzzle. First thing first though, the Debian wiki keyboard page contains significant amount of info. Unfortunately the Debian wiki pages can sometimes be out of date and are not always clear and concise. Still it's probably the sensible place to start.

First thing that jumps out at me is that is says that 'console-setup' also needs to be installed, and I don't appear to have that pre-installed by default. So perhaps just try installing that and re-running the steps you've already tried.

It does also note that restarting the 'keyboard-setup' service isn't sufficient, that you also need to run:

udevadm trigger --subsystem-match=input --action=change

(or reboot)

FWIW, (probably obviously) the X11 related stuff is irrelevant and 'setxkbmap' isn't installed (and probably wouldn't help anyway). I'm also pretty sure that none of the troubleshooting steps are relevant to us either.

It does mention use of the setupcon command (which is part of the console-setup package noted above). So fingers crossed, installing that will hopefully be all you need. The the keyboard config file man page might also be worth a glace (but probably won't lead directly a fix).

One thing I did note on the wiki page that I had previously overlooked, is setting keyboard layout for the initramfs (for keyboard use in early boot). Under ideal circumstance, it won't be needed, but for completeness, we should do that! I.e. Tweak /etc/initramfs-tools/initramfs.conf and ensure that "KEYMAP=y"!

Please let me know how you go either way!

If the about fixes it, then I'll update the confconsole script.

If it doesn't, then I'm not sure really, but I'm happy to try digging a bit deeper.

Add new comment