per-window keyboard layouts

Hi all, I made a layout modifier that saves per-window keyboard layouts and restores them on focus changes. Quite handy when working with several keyboard layouts as there's no external program which provides this functionality AND works with XMonad: kkbswitch is abandoned, xxkb fails to detect focus changes correctly. So here it is: http://hpaste.org/fastcgi/hpaste.fcgi/view?id=24371 However I'm not sure if I should send it to contrib: it heavily depends on FFI and requires X header files to compile. Usage: either drop as XKBLayout.hsc in contrib/XMonad/Layout , add to xmonad-contrib.cabal and rebuild Or put into ~/.xmonad/lib/XMonad/Layout as XKBLayout.hsc and run through hsc2hs Then follow instructions from the header. Basically just import and add to the layout hook. xxkb can still be used as an indicator

Nice work, this looks like something I myself would find quite useful!
This seems like the perfect kind of thing for xmonad-extras, a sort of
"no-man's land" for extensions that are hard to compile for one reason
or another.
~d
Quoting Konstantin Sobolev
Hi all,
I made a layout modifier that saves per-window keyboard layouts and restores them on focus changes. Quite handy when working with several keyboard layouts as there's no external program which provides this functionality AND works with XMonad: kkbswitch is abandoned, xxkb fails to detect focus changes correctly.
So here it is: http://hpaste.org/fastcgi/hpaste.fcgi/view?id=24371
However I'm not sure if I should send it to contrib: it heavily depends on FFI and requires X header files to compile.
Usage: either drop as XKBLayout.hsc in contrib/XMonad/Layout , add to xmonad-contrib.cabal and rebuild Or put into ~/.xmonad/lib/XMonad/Layout as XKBLayout.hsc and run through hsc2hs Then follow instructions from the header. Basically just import and add to the layout hook.
xxkb can still be used as an indicator

* On Thursday, March 25 2010, wagnerdm@seas.upenn.edu wrote:
Nice work, this looks like something I myself would find quite useful! This seems like the perfect kind of thing for xmonad-extras, a sort of "no-man's land" for extensions that are hard to compile for one reason or another. ~d
Quoting Konstantin Sobolev
: Hi all,
...
Usage: either drop as XKBLayout.hsc in contrib/XMonad/Layout , add to xmonad-contrib.cabal and rebuild Or put into ~/.xmonad/lib/XMonad/Layout as XKBLayout.hsc and run through hsc2hs Then follow instructions from the header. Basically just import and add to the layout hook.
xxkb can still be used as an indicator
I don't see any problems to include this in contrib: To compile XMonad core you need hsc2hs seeing as there is a file XMonad/Main.hsc. hsc2hs is included with ghc-6.12 and I'm almost certain that it was shipped with earlier versions too. XMonad core uses a hsc file too. Perhaps the XKB binding is somthing that should be part of X11 or a separate package on hackage. -- Adam

On Mar 27, 2010, at 02:24 , Adam Vogt wrote:
hsc2hs is included with ghc-6.12 and I'm almost certain that it was shipped with earlier versions too. XMonad core uses a hsc file too.
Back to 6.6 at least. -- brandon s. allbery [solaris,freebsd,perl,pugs,haskell] allbery@kf8nh.com system administrator [openafs,heimdal,too many hats] allbery@ece.cmu.edu electrical and computer engineering, carnegie mellon university KF8NH

Hello,
On Sat, Mar 27, 2010 at 2:24 AM, Adam Vogt
I don't see any problems to include this in contrib: To compile XMonad core you need hsc2hs seeing as there is a file XMonad/Main.hsc.
Many thanks for the feedback. Here's a rewritten eventHook-based version that uses ExtensibleState: http://hpaste.org/fastcgi/hpaste.fcgi/view?id=24464 Compiles cleanly with ghc-6.10, unfortunately I don't have 6.12 to try it there. I wasn't aware of ExtensibleState since I was still on a 0.9.1 codebase.. nice stuff. Docks aren't still recognized, even with getInputFocus from Graphics.X11.Xlib.Misc instead of XMonad's W.focus I'll send a patch to contrib once there're no pending corrections.

Update. First version works incorrectly with multiple workspaces due
to the fact that XMonad creates separate Layout copy for every
workspace, so we get a number of independent LayoutModifer (custom
data) instances instead of just one. (By the way, why is it
necessary?)
It took me some time to find a workaround; it assumes that different
workspaces have different tags. Here it goes, version 2:
http://hpaste.org/fastcgi/hpaste.fcgi/view?id=24417
It still has some problems though, e.g. doesn't recognize prompt
window, and I'm not sure it's possible to fix it without resorting to
low-level X programming; there seems to be no way to intercept the
moment when this window comes and goes.
On Thu, Mar 25, 2010 at 6:10 PM, Konstantin Sobolev
Hi all,
I made a layout modifier that saves per-window keyboard layouts and restores them on focus changes. [...]

* On Saturday, March 27 2010, Konstantin Sobolev wrote:
Update. First version works incorrectly with multiple workspaces due to the fact that XMonad creates separate Layout copy for every workspace, so we get a number of independent LayoutModifer (custom data) instances instead of just one. (By the way, why is it necessary?)
For writing actual layouts, keeping layout state per workspace makes more sense (think about what would happen with dual monitors, different layouts per workspace...). It's much easier to go to global state from workspace-local state than the other way around.
It took me some time to find a workaround; it assumes that different workspaces have different tags. Here it goes, version 2:
This assumption is probably true, but I'm not sure how it would compare to keeping track based on the index in the output of W.workspaces... Perhaps it would be better to implement this as a handleEventHook.
Here are some suggestions to shorten the code:
-- Adam
participants (4)
-
Adam Vogt
-
Brandon S. Allbery KF8NH
-
Konstantin Sobolev
-
wagnerdm@seas.upenn.edu