[xmonad] Ratpoison key emulation

Jérémy Bobbio lunar at debian.org
Thu Jul 3 19:46:12 EDT 2008


On Sun, Jun 29, 2008 at 08:38:57AM -0400, Gwern Branwen wrote:
> Hiya everyone. So as I've long mused about, I've gotten around to
> seeing how difficult it'd be to do a Ratpoison style keymap for
> XMonad. It went reasonably well, but I've run into a number of
> Ratpoison commands where I can't see what to bind them to (or whether
> the functionality is implemented in XMC somewhere I just don't know
> about), so I thought I'd demonstrate what I have and see whether
> anyone has any suggestions.
> 
> The code is as follows:
> 
> {- Not implemented:
> […]
> C-t t
>     Sometimes you need to send a C-t to the current window. This
>     keystroke does just that.

If you ever want to implement this, here's a function that might be
useful:

sendKey :: Window -> KeyMask -> KeySym -> X ()
sendKey w mods key = withDisplay $ \d -> do
              rootw <- asks theRoot
              keycode <- io $ keysymToKeycode d key
              io $ allocaXEvent $ \ev -> do
                  setEventType ev keyPress
                  setKeyEvent ev w rootw none mods keycode True
                  sendEvent d w True keyPressMask ev
                  setEventType ev keyRelease
                  sendEvent d w True keyReleaseMask ev

It works fine in my own xmonad.hs (which I unfortunately never found the
time to turn into a proper extension).

Cheers,
-- 
Jérémy Bobbio                        .''`. 
lunar at debian.org                    : :Ⓐ  :  # apt-get install anarchism
                                    `. `'` 
                                      `-   
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: Digital signature
Url : http://www.haskell.org/pipermail/xmonad/attachments/20080704/3571e83a/attachment.bin


More information about the xmonad mailing list