[xmonad] CycleRecentWS with nonempty workspaces only

Wirt Wolff wirtwolff at gmail.com
Sat Jan 23 16:32:43 EST 2010

Excerpts from Ralph Hofmann's message of Sat Jan 23 03:02:43 -0700 2010:
> I would like to have cycleRecentWS of XMonad.Actions.CycleRecentWS to
> cycle the nonempty workspaces only. Can anybody point my the way to
> achieve this? (The conventional if-then stuff is a mystery in
> haskell;-))

That's a neat idea. I'm sort of surprised no one seems to have
asked for it before. Since my haskell and xmonad hacking are a
bit rusty there's likely a better way to do this, but I've
attached an example file with some helper functions and
keybindings showing how to use cycleWindowSets from
CycleRecentWS to do what you want. Although it could be tweaked
to act differently on the other visible workspaces with
multi-head, the example focuses them in turn, but never moves a
visible workspace to another screen, which seems like the nicest
alternative overall.

The key to making sense of the code is that empty workspaces
have Nothing for their Stacks, so using pattern matching and a
list comprehension is one clear and simple way to get the tags
of the nonempty workspaces in the right order. Then
cycleRecentWS uses that list to generate a list of windowsets
for each choice you could make while cycling in "preview" mode.
The example is liberally commented, but please ask if it's
unclear how any of the parts work or fit together to produce the
final result.

-------------- next part --------------
A non-text attachment was scrubbed...
Name: cycleNonEmptyWS.hs
Type: application/octet-stream
Size: 1396 bytes
Desc: not available
Url : http://www.haskell.org/pipermail/xmonad/attachments/20100123/e0c2dd6e/cycleNonEmptyWS.obj

More information about the xmonad mailing list