two beginner's questions on XMonad config

Hello, I'm new both to Haskell and XMonad, so please bear with me if these questions are too much off-topic... 1) Since I have no modifier keys left on my laptop, and I'm an Emacs user (which takes away many C- and M- keybindings), I'd like to bind most XMonad actions with "C-z" as a prefix (using EZConfig). Is there a way to bind a key so that "C-z C-z" sends a C-z to the currently focused window? (Ratpoison has a similar feature for C-t) 2) Is there a variant of the Tall layout that does not resize the tiled non-master windows, but just pile them aside so that the one corner is visible and part of the window is offscreen? (larswm has this feature, called "tile_no_resize") This would be useful for rxvt's, which tend to erase part of the terminal after resizes. Is there a way to flag certain windows so that they are not resized? Thank you very much in advance! Riccardo

On Tue, Dec 09, 2008 at 08:17:39PM +0000, Riccardo Murri wrote:
Hello, ...
1) Since I have no modifier keys left on my laptop, and I'm an Emacs user (which takes away many C- and M- keybindings),
not really what you asked, but how about the capslock key? you can remap it to a mod like mod3, for example, and then set modMask = mod3Mask in your config and be done with it. see man xmodmap A

Riccardo Murri
1) Since I have no modifier keys left on my laptop, and I'm an Emacs user (which takes away many C- and M- keybindings), I'd like to bind most XMonad actions with "C-z" as a prefix (using EZConfig).
Is there a way to bind a key so that "C-z C-z" sends a C-z to the currently focused window? (Ratpoison has a similar feature for C-t)
I did some googling and found out that: 1) the quickest solution is to use "xdotool" [http://www.semicomplete.com/projects/xdotool/], which can (among other nifty things), send a fake keypress to the currently focused window:: ("C-z C-z", spawn "xdotool key ctrl+z") 2) According to: http://www.handhelds.org/moin/moin.cgi/GeneratingSyntheticX11Events there are two Xlib programmatic solution, one using the XTest extension (recommended), and one using XSendEvent(). As far as I understand, there are no bindings for XTest in the Graphics.X11 module, so one has to code using sendEvent... With the following code, I have been able to send a Ctrl+Z to urxvt and "xev" windows directly from XMonad:: -- send Ctrl+Z to focused window sendCtrlZ = sendKey controlMask xK_z sendKey modmask keysym = withDisplay $ \d -> do keycode <- io $ keysymToKeycode d keysym root <- asks theRoot let subw = none -- FIXME: should this be the subwindow which the pointer is in? withFocused $ \w -> do io $ allocaXEvent $ \ev -> do setEventType ev keyPress setKeyEvent ev w root subw modmask keycode True sendEvent d w False noEventMask ev io $ allocaXEvent $ \ev -> do setEventType ev keyRelease setKeyEvent ev w root subw modmask keycode True sendEvent d w False noEventMask ev return () Thanks to all those who replied with suggestions to my original post! Cheers, Riccardo

On Fri, Dec 12, 2008 at 12:53:15AM +0000, Riccardo Murri wrote:
Riccardo Murri
writes: 1) Since I have no modifier keys left on my laptop, and I'm an Emacs user (which takes away many C- and M- keybindings), I'd like to bind most XMonad actions with "C-z" as a prefix (using EZConfig).
Is there a way to bind a key so that "C-z C-z" sends a C-z to the currently focused window? (Ratpoison has a similar feature for C-t)
I did some googling and found out that:
1) the quickest solution is to use "xdotool" [http://www.semicomplete.com/projects/xdotool/], which can (among other nifty things), send a fake keypress to the currently focused window::
("C-z C-z", spawn "xdotool key ctrl+z")
Nifty! Would you mind adding this to the FAQ page on the wiki as a lightweight solution? Many people have asked for this.
2) According to:
http://www.handhelds.org/moin/moin.cgi/GeneratingSyntheticX11Events
there are two Xlib programmatic solution, one using the XTest extension (recommended), and one using XSendEvent(). As far as I understand, there are no bindings for XTest in the Graphics.X11 module, so one has to code using sendEvent...
With the following code, I have been able to send a Ctrl+Z to urxvt and "xev" windows directly from XMonad::
I could have sworn there was already a contrib module that does this, using code similar to what you wrote. But I can't find it. Perhaps it just got kicked around on the ML but never actually made it into the repo. Anyway, the xdotool is a nice solution regardless. -Brent

Brent Yorgey
1) the quickest solution is to use "xdotool" [http://www.semicomplete.com/projects/xdotool/], which can (among other nifty things), send a fake keypress to the currently focused window::
("C-z C-z", spawn "xdotool key ctrl+z")
Nifty! Would you mind adding this to the FAQ page on the wiki as a lightweight solution? Many people have asked for this.
Done.
With the following code, I have been able to send a Ctrl+Z to urxvt and "xev" windows directly from XMonad::
I could have sworn there was already a contrib module that does this, using code similar to what you wrote. But I can't find it. Perhaps it just got kicked around on the ML but never actually made it into the repo. Anyway, the xdotool is a nice solution regardless.
XMonad.Util.Paste (found by grepping the sources in the darcs repo). I have added a mention to it in the FAQ above. Will it be released in 0.9? Cheers, Riccardo
participants (3)
-
Andrew Sackville-West
-
Brent Yorgey
-
Riccardo Murri