I'd like to perform some actions when the user requests a keyboard layout change (via ibus/setxkbmap/wayland/gnome/plasma/…), notably in order to disable KMonad (otherwise the user-defined layout might conflict with KMonad's layout… I'm just afraid that killing KMonad would reset the layout but this is another question). Is there an efficient and portable way to detect if a keyboard change occurred, or, even better, to hook right before the keyboard change occured? I was planning to use:
$ setxkbmap -query
rules: evdev
model: pc86
layout: fr
variant: bepo_afnor
options: ctrl:swapcaps
It seems to work for both Ibus & setxkbmap, but first this is unlikely to work with Wayland (but I need to check), and, most importantly, I don't to run this command every second as it would consume CPU resources for no reasons.
Is there a more portable & efficient solution?
Asked by tobiasBora
(4621 rep)
May 22, 2024, 08:22 AM