[xmonad] Stash and replace for workspace?

Norbert Zeh nzeh at cs.dal.ca
Thu Jun 25 13:59:16 EDT 2009


On Thu, Jun 25, 2009 at 01:52:19PM -0400, wagnerdm at seas.upenn.edu wrote:
> 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  
> ScreenDetail
> 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!

Thanks.  In the meantime I couldn't resist hacking and came up with the
same solution ;)  The only thing I noticed is that swapping the screens
as above (which is what I also did first) also moves the focus between
screens.  The trick to get the behaviour I want is to swap the workspace
inside (current ss) and (head . visible $ ss), as this does not touch
the screens, only the associated workspaces.

In any case, thanks a lot for answering.  If it's not there already, do
we think this is something worthwhile to put into XMonadContrib?

Cheers,
Norbert

-- 
"And it happened all the time that the compromise between two perfectly
rational alternatives was something that made no sense at all."
  -- Neal Stephenson, Anathem


More information about the xmonad mailing list