CPCWiki forum

General Category => Off topic => Topic started by: arnoldemu on 09:16, 15 October 13

Title: detecting keyboard layout under linux
Post by: arnoldemu on 09:16, 15 October 13
Does anyone know how to detect the keyboard layout under linux???

C or C++ code please.

I know how to do this under windows. wxwidgets doesn't seem to have a function to help me.

I believe I need to use kbdd???



Title: Re: detecting keyboard layout under linux
Post by: Sykobee (Briggsy) on 09:42, 15 October 13
Well, on the command line:

setxkbmap -print | awk -F"+" '/xkb_symbols/ {print $2}'

so I'd look at the source for setxkbmap to see what it does?

Actually, the -query option might be better.

setxkbmap -query | grep layout


If you are detecting keyboard layout so in English you use (e.g.,) WASD and in French you use ZQSD, for example, you could have the startup script for the tool configure a settings file for the application with the correct key-codes?
Title: Re: detecting keyboard layout under linux
Post by: redbox on 12:18, 15 October 13
Quote from: Sykobee (Briggsy) on 09:42, 15 October 13
setxkbmap -print | awk -F"+" '/xkb_symbols/ {print $2}'

setxkbmap works with X but does it work under the command line as well?
Title: Re: detecting keyboard layout under linux
Post by: Sykobee (Briggsy) on 12:43, 15 October 13
localectl might work? It doesn't on X though, but it might in a plain text-mode console.
Title: Re: detecting keyboard layout under linux
Post by: arnoldemu on 13:05, 15 October 13
Quote from: Sykobee (Briggsy) on 12:43, 15 October 13
localectl might work? It doesn't on X though, but it might in a plain text-mode console.

so many possibilities :(

On windows it is soo easy.

So I want to detect the keyboard language so I can configure my emulator automatically.

Title: Re: detecting keyboard layout under linux
Post by: Sykobee (Briggsy) on 14:04, 15 October 13
And then there's Wayland and Mir ... hopefully they use a compatible keyboard system to X so you don't need completely new tools there.


Really there should be an API to get this information. File a bug against wxWindows :p
Powered by SMFPacks Menu Editor Mod