开发者

Python - detect keyboard layout

开发者 https://www.devze.com 2023-01-02 19:01 出处:网络
Playing around with RFID reader in serial, using python to output to console through ui开发者_如何学JAVAnput/

Playing around with RFID reader in serial, using python to output to console through ui开发者_如何学JAVAnput/

The thing is, doing the conversion from fake-rfid-keyboard-codes to code sent to uinput/, I would better know if I am using a QWERTY or an AZERTY ('a' becoming 'q', etc...)

Back here in Belgium, especially during the event I am working on we are highly susceptible to have both keyboard layouts, I have to support both 'on-the-fly'

Any os.*() function to do the job?

Thanx !


You could start by looking at setxkbmap -print, but generally this is nontrivial.

Why not instead set the keyboard layout to QWERTY for the virtual keyboard device you're creating with uinput? X supports separate layouts for each device.

xinput list                   # find the device ID, say, 12
setxkbmap -device 12 us       # use it

In my experience, whenever I plug in an external USB keyboard it always starts out as US English, so I'm not sure that's even necessary.

0

精彩评论

暂无评论...
验证码 换一张
取 消