The other day I blogged about my frustration over Opera not recognizing when I changed keymaps with setxkbmap. Well, it turned out that not only Opera had a problem, but all Qt and Gtk2 applications. (I guess that tells a bit about me that I haven’t realized this until now).
My ~/.fluxbox/keys file contained the follwing lines, which worked well in the applications that I happen to use most of the time (rxvt-unicode, vim):
Mod4 G :Exec setxkbmap -layout gh -variant ga
Mod4 S :Exec setxkbmap -layout se -variant nodeadkeys
Mod4 U :Exec setxkbmap -layout us
I noticed one thing. If I changed the keymap before launching Opera, the browser would use that keymap. So if, at the time of starting Opera, I was using a Swedish keymap, then I would be able to enter Swedish keys in Opera. But changing the keymap while Opera was running had no effect.
The fix for the problem was simple, after a bit of Googling. I modified ~/.xinitrc to look as follows:
setxkbmap -option grp:switch,grp:shift_toggle,grp_led:scroll us,se,gh -variant ',,ga'
Now the few Qt and Gtk applications that I use behave well! I can switch between US, Swedish and Ga keyboards in all X applications.
Moral: if somethings doesn’t work as you like, don’t get frustrated, get searching. Somebody has had the problem before, fixed it and documented it.