[xmonad] Stash and replace for workspace?

wagnerdm at seas.upenn.edu wagnerdm at seas.upenn.edu
Thu Jun 25 13:52:19 EDT 2009

Quoting Norbert Zeh <nzeh at cs.dal.ca>:

> assume that I am currently looking at workspace A on the primary screen,
> while the secondary screen shows workspace B.  Next I need to do some
> work on workspace C, but I would like to keep what I did on WS A
> visible.  So I'd like to create a keybinding that shunts A off to my
> secondary screen (replacing B) and brings up C on my primary screen
> (replacing A).
> Now here's the question:  Is there a simple and elegant way to do this
> with the functions available in XMonadContrib?  If not, am I right in
> assuming that I have to do some stackset surgery to achieve this?  Any
> pointers are appreciated.

I'm not sure if there's anything already in XMonadContrib, but it  
should be totally easy to write on your own.  We have

windows :: (WindowSet -> WindowSet) -> X ()
type WindowSet = StackSet WorkspaceId (Layout Window) Window ScreenId  
data StackSet i l a sid sd = StackSet {
   current :: Screen i l a sid sd,
   visible :: [Screen i l a sid sd],

So, we could maybe define a cycleScreens function:

cycleScreens :: WindowSet -> WindowSet
cycleScreens ss@(StackSet { current = c, visible = vs }) = let  
(c':vs') = vs ++ [c] in ss { current = c', visible = vs' }

Then the keybindings you're asking for would something like

[((modMask conf, key), windows (greedyView name . cycleScreens)) |  
(key, name) <- zip [xK_1 .. xK_9] (workspaces conf)]

Note: this is all extemporaneous, not tested or even type-checked, so  
use at your own risk!


More information about the xmonad mailing list