Is there an API to query setxkbmap's current layout?
1
vote
0
answers
105
views
A bit related to [this previous question of mine](https://unix.stackexchange.com/questions/723777/how-do-you-use-keyboard-driven-programs-with-non-latin-alphabet-keyboards) , I wonder if there's a way to query what is the current layout.
Say I have run
setxkbmap -layout it,ru -variant ,phonetic -option 'grp:caps_toggle'
and that I've presset CapsLock a few times. How can I tell programmatically what of 2 states I'm in?
Interactively I can simply type some characters to check, but I want to do it programmatically, so I can have that state printed in a status bar or something.
---
I was also thinking of some hack, like synthetically hitting CapsLockfCapsLockf, and then checking whether the output is фf
or fф
, which would tell me the current layout is it
or ru
respectively.
[xdotool
seemed the correct tool for this](https://unix.stackexchange.com/questions/267704/command-to-simulate-keyboard-input) , but unfortunately Caps_Lock
corresponds to the _function_ of the ordinary CapsLock key, and not to what the setxkbmap
command above has set it to, so this
xdotool key Caps_Lock f Caps_Lock f
results in Ff
regardless of what layout is active.
Asked by Enlico
(2258 rep)
Nov 6, 2022, 08:25 AM
Last activity: Nov 6, 2022, 08:49 AM
Last activity: Nov 6, 2022, 08:49 AM