How to make per-window keyboard layouts?

Greetings, I've been using plain XMonad for some time (not combined with KDE/GNome). Currently, I'm switching between keyboard layouts simply by a key combination globally: [ ((modMask , xK_Scroll_Lock ), spawn "setxkbmap -layout us ; xmodmap ~/.Xmodmap") , ((modMask .|. shiftMask, xK_Scroll_Lock), spawn "setxkbmap -layout cz ; xmodmap ~/.Xmodmap") ] However that's a bit inconvenient. For many windows (i.e. browser, terminal) I need to keep the US layout most of the time. I need the localized layout only for text editors in 99% of cases. And I switch windows/workspaces a lot, so I have to switch the layouts manually almost every time I switch. Ideally I'd like to achieve: - By pressing the key combination I set some kind of flag for the currently focused window. - XMonad calls the spawn "setxkbmap ..." commands automatically according to the flags when window focus changes. How to do that (if it's possible)? Thanks for help. (Bonus: Manage the flags externally by some kind of command from scripts.) (I asked this on superuser.com, but so far with no success: http://superuser.com/q/486259/162491) Best regards, Petr Pudlak

On Thu, Oct 25, 2012 at 5:57 AM, Petr P
However that's a bit inconvenient. For many windows (i.e. browser, terminal) I need to keep the US layout most of the time. I need the localized layout only for text editors in 99% of cases. And I switch windows/workspaces a lot, so I have to switch the layouts manually almost every time I switch.
https://bbs.archlinux.org/viewtopic.php?id=82891 might be of interest. (It's not Arch-specific, although I can't promise that your system has xxkb packaged.) -- brandon s allbery kf8nh sine nomine associates allbery.b@gmail.com ballbery@sinenomine.net unix/linux, openafs, kerberos, infrastructure http://sinenomine.net

Thu, Oct 25, 2012 at 11:36:56AM -0400, Brandon Allbery wrote
On Thu, Oct 25, 2012 at 5:57 AM, Petr P
wrote: However that's a bit inconvenient. For many windows (i.e. browser, terminal) I need to keep the US layout most of the time. I need the localized layout only for text editors in 99% of cases. And I switch windows/workspaces a lot, so I have to switch the layouts manually almost every time I switch.
https://bbs.archlinux.org/viewtopic.php?id=82891 might be of interest. (It's not Arch-specific, although I can't promise that your system has xxkb packaged.)
-- brandon s allbery kf8nh sine nomine associates allbery.b@gmail.com ballbery@sinenomine.net unix/linux, openafs, kerberos, infrastructure http://sinenomine.net
Xxkb has some problems with non-reparenting WM like xmonad, same for Xneur. However there was per-window-layout module in xmonad-extras and you can try to use kbdd (self adv), it packages exists for gentoo, debian. If you are using xmonad without ICCCWM hook then you can use pre 0.6.2 version as it latest non-ICCCWM support is dropped until I found a good way to monitor system changes. [1] https://github.com/qnikst/kbdd -- Alexander V Vershilov.
participants (3)
-
Alexander V Vershilov
-
Brandon Allbery
-
Petr P