[xmonad] How to make per-window keyboard layouts?

Petr P petr.mvd at gmail.com
Thu Oct 25 11:57:18 CEST 2012


  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



More information about the xmonad mailing list