xmonad-contrib-0.7: Third party extensions for xmonadContentsIndex
XMonad.Actions.CycleWS
Portabilityunportable
Stabilityunstable
MaintainerJoachim Breitner <mail@joachim-breitner.de>
Contents
Usage
Moving between workspaces
Moving between screens (xinerama)
Moving between workspaces, take two!
The mother-combinator
Description

Provides bindings to cycle forward or backward through the list of workspaces, to move windows between workspaces, and to cycle between screens. More general combinators provide ways to cycle through workspaces in various orders, to only cycle through some subset of workspaces, and to cycle by more than one workspace at a time.

Note that this module now subsumes the functionality of the former XMonad.Actions.RotView. Former users of rotView can simply replace rotView True with moveTo Next NonEmptyWS, and so on.

If you want to exactly replicate the action of rotView (cycling through workspace in order lexicographically by tag, instead of in the order specified in the config), it can be implemented as:

 rotView b  = do t <- findWorkspace getSortByTag (bToDir b) NonEmptyWS 1
                 windows . greedyView $ t
   where bToDir True  = Next
         bToDir False = Prev
Synopsis
nextWS :: X ()
prevWS :: X ()
shiftToNext :: X ()
shiftToPrev :: X ()
toggleWS :: X ()
nextScreen :: X ()
prevScreen :: X ()
shiftNextScreen :: X ()
shiftPrevScreen :: X ()
swapNextScreen :: X ()
swapPrevScreen :: X ()
data WSDirection
= Next
| Prev
data WSType
= EmptyWS
| NonEmptyWS
| HiddenNonEmptyWS
| AnyWS
| WSIs (X (WindowSpace -> Bool))
shiftTo :: WSDirection -> WSType -> X ()
moveTo :: WSDirection -> WSType -> X ()
findWorkspace :: X WorkspaceSort -> WSDirection -> WSType -> Int -> X WorkspaceId
Usage

You can use this module with the following in your ~/.xmonad/xmonad.hs file:

 import XMonad.Actions.CycleWS

 -- a basic CycleWS setup

   , ((modMask x,               xK_Down),  nextWS)
   , ((modMask x,               xK_Up),    prevWS)
   , ((modMask x .|. shiftMask, xK_Down),  shiftToNext)
   , ((modMask x .|. shiftMask, xK_Up),    shiftToPrev)
   , ((modMask x,               xK_Right), nextScreen)
   , ((modMask x,               xK_Left),  prevScreen)
   , ((modMask x .|. shiftMask, xK_Right), shiftNextScreen)
   , ((modMask x .|. shiftMask, xK_Left),  shiftPrevScreen)
   , ((modMask x,               xK_z),     toggleWS)

If you want to follow the moved window, you can use both actions:

   , ((modMask x .|. shiftMask, xK_Down), shiftToNext >> nextWS)
   , ((modMask x .|. shiftMask, xK_Up),   shiftToPrev >> prevWS)

You can also get fancier with moveTo, shiftTo, and findWorkspace. For example:

   , ((modMask x     , xK_f), moveTo Next EmptyWS)  -- find a free workspace
   , ((modMask x .|. controlMask, xK_Right),        -- a crazy keybinding!
         do t <- findWorkspace getXineramaWsCompare Next NonEmptyWS 2
            windows . view $ t                                         )

For detailed instructions on editing your key bindings, see XMonad.Doc.Extending#Editing_key_bindings.

Moving between workspaces

The following commands for moving the view and windows between workspaces are somewhat inflexible, but are very simple and probably Do The Right Thing for most users.

All of the commands in this section cycle through workspaces in the order in which they are given in your config.

nextWS :: X ()
Switch to the next workspace.
prevWS :: X ()
Switch to the previous workspace.
shiftToNext :: X ()
Move the focused window to the next workspace.
shiftToPrev :: X ()
Move the focused window to the previous workspace.
toggleWS :: X ()
Toggle to the workspace displayed previously.
Moving between screens (xinerama)
nextScreen :: X ()
View next screen
prevScreen :: X ()
View prev screen
shiftNextScreen :: X ()
Move focused window to workspace on next screen
shiftPrevScreen :: X ()
Move focused window to workspace on prev screen
swapNextScreen :: X ()
Swap current screen with next screen
swapPrevScreen :: X ()
Swap current screen with previous screen
Moving between workspaces, take two!

A few more general commands are also provided, which allow cycling through subsets of workspaces.

For example,

   moveTo Next EmptyWS

will move to the first available workspace with no windows, and

   shiftTo Prev (WSIs $ return (('p' `elem`) . tag))

will move the focused window backwards to the first workspace containing the letter p in its name. =)

data WSDirection
Direction to cycle through the sort order.
Constructors
Next
Prev
data WSType
What type of workspaces should be included in the cycle?
Constructors
EmptyWScycle through empty workspaces
NonEmptyWScycle through non-empty workspaces
HiddenNonEmptyWScycle through non-empty non-visible workspaces
AnyWScycle through all workspaces
WSIs (X (WindowSpace -> Bool))cycle through workspaces satisfying an arbitrary predicate
shiftTo :: WSDirection -> WSType -> X ()
Move the currently focused window to the next workspace in the given direction that satisfies the given condition.
moveTo :: WSDirection -> WSType -> X ()
View the next workspace in the given direction that satisfies the given condition.
The mother-combinator
findWorkspace :: X WorkspaceSort -> WSDirection -> WSType -> Int -> X WorkspaceId

Given a function s to sort workspaces, a direction dir, a predicate p on workspaces, and an integer n, find the tag of the workspace which is n away from the current workspace in direction dir (wrapping around if necessary), among those workspaces, sorted by s, which satisfy p.

For some useful workspace sorting functions, see XMonad.Util.WorkspaceCompare.

For ideas of what to do with a workspace tag once obtained, note that moveTo and shiftTo are implemented by applying (>>= (windows . greedyView)) and (>>= (windows . shift)), respectively, to the output of findWorkspace.

Produced by Haddock version 0.8