From owner-freebsd-questions@FreeBSD.ORG Wed May 15 13:27:23 2013 Return-Path: Delivered-To: freebsd-questions@freebsd.org Received: from mx1.freebsd.org (mx1.FreeBSD.org [8.8.178.115]) by hub.freebsd.org (Postfix) with ESMTP id 20963F78 for ; Wed, 15 May 2013 13:27:23 +0000 (UTC) (envelope-from freebsd@edvax.de) Received: from mx02.qsc.de (mx02.qsc.de [213.148.130.14]) by mx1.freebsd.org (Postfix) with ESMTP id E08C4DAD for ; Wed, 15 May 2013 13:27:22 +0000 (UTC) Received: from r56.edvax.de (port-92-195-6-62.dynamic.qsc.de [92.195.6.62]) by mx02.qsc.de (Postfix) with ESMTP id 76A4227628; Wed, 15 May 2013 15:27:15 +0200 (CEST) Received: from r56.edvax.de (localhost [127.0.0.1]) by r56.edvax.de (8.14.5/8.14.5) with SMTP id r4FDRPBd002034; Wed, 15 May 2013 15:27:25 +0200 (CEST) (envelope-from freebsd@edvax.de) Date: Wed, 15 May 2013 15:27:24 +0200 From: Polytropon To: Matthias Apitz Subject: Re: detecting keyboard layout during boot Message-Id: <20130515152724.1ef31a58.freebsd@edvax.de> In-Reply-To: <20130515073554.GA1098@tiny.Sisis.de> References: <20130515073554.GA1098@tiny.Sisis.de> Organization: EDVAX X-Mailer: Sylpheed 3.1.1 (GTK+ 2.24.5; i386-portbld-freebsd8.2) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Cc: freebsd-questions@freebsd.org X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list Reply-To: Polytropon List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 15 May 2013 13:27:23 -0000 On Wed, 15 May 2013 09:35:54 +0200, Matthias Apitz wrote: > > Hello, > > I have in /etc/rc.conf a line > > keymap="german.iso" > > to set the keyboard to German; as the system in question is on an USB > key for boot and sometimes used in other laptops with QWERTY layout, I > would like to have it adapt itself to the actual layout without changing > anything before booting in rc.conf and without asking the user to press > a key ... is there some way to detect the actual keyboard layout > automagically? Basically, it's impossible, but it can be made possible by the power of FreeBSD. :-) Allow me to explain: Depending on where the keyboard is attached, some connections (AT 5 pin plug, PS/2 6 pin mini-plug) do not offer any means to detect what keyboard is connected (or even _if_ a keyboard is connected). This case usually applies to keyboards built into laptops. You can see that in "dmesg | grep kbd". Example: % dmesg | grep kbd kbd1 at kbdmux0 atkbdc0: at port 0x60,0x64 on isa0 atkbd0: irq 1 on atkbdc0 kbd0 at atkbd0 atkbd0: [GIANT-LOCKED] atkbd0: [ITHREAD] ukbd0: on usbus1 kbd2 at ukbd0 You see: The AT keyboard controller is detected, kbd0 is available. But there is no actual keyboard connected to that PS/2 port. Instead, a Sun USB Type 7 keyboard (german layout) is being used here, as kbd2. But as you're asking about USB, there is a way. But this way depends on how the manufacturer cooperates. Let's discuss that. As you know, every USB device is characterized by two specific USB numbers: vendor ID and product ID. In some cases, the product ID is different regarding the language layout, but you need to test that individually, no standard seems to exist. Then, you can use the devd.conf file to select per this ID and load the correct keyboard layout. This is done in the "rc.conf stage". Prior to this stage, the "kernel stage", you can hardcode layouts in the kernel config. Last time I checked this stopped working, I have been told that the use of kbdmux is the reason for this observation. Example: options ATKBD_DFLT_KEYMAP makeoptions ATKBD_DFLT_KEYMAP=german.iso options UKBD_DFLT_KEYMAP makeoptions UKBD_DFLT_KEYMAP=german.iso Those options would enable a german keyboard layout even in SUM. Even adding a font for proper display has been possible: options SC_DFLT_FONT makeoptions SC_DFLT_FONT=iso Not sure if this is still supported. Using Umlauts and Eszett is discouraged in filenames, and the blind knowledge of the US keyboard layout is quite standard among sysadmins. :-) As a summery: No soup for you! ;-) -- Polytropon Magdeburg, Germany Happy FreeBSD user since 4.0 Andra moi ennepe, Mousa, ...