1

A bit related to this previous question of mine, 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 , which would tell me the current layout is it or ru respectively.

xdotool seemed the correct tool for this, 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.

Enlico
  • 1,471
  • 16
  • 35
  • Does this help? [check-lock-keys-state-from-command-line](https://askubuntu.com/questions/541784/check-lock-keys-state-from-command-line) – aviro Nov 06 '22 at 11:44
  • @aviro, no, it doesn't. Like `xdotool` seems to not know about the behavioral change that `setxkbmap` has applied to CapsLock. – Enlico Nov 06 '22 at 11:52

0 Answers0