[xmonad] Ratpoison key emulation

Gwern Branwen gwern0 at gmail.com
Sat Jul 12 00:34:18 EDT 2008


On 2008.07.04 01:46:12 +0200, Jérémy Bobbio <lunar at debian.org> scribbled 2.4K characters:
> 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                        .''`.

Thanks for the code, Jeremy; I've long wanted a function to send keys to windows. I was thinking of adding it to XSelection, but what limits does this function have, do you know? X is often difficult to deal with. Does it handle odd characters?

--
gwern
Undercover burhop World 757 William BECCA Psyops veggie 3M Treasury
-------------- 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/20080712/f63b8ef2/attachment.bin


More information about the xmonad mailing list