<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /><title>XMonad.Actions.CycleWS</title><link href="ocean.css" rel="stylesheet" type="text/css" title="Ocean" /><script src="haddock-util.js" type="text/javascript"></script><script type="text/javascript">//<![CDATA[ window.onload = function () {pageLoad();setSynopsis("mini_XMonad-Actions-CycleWS.html");}; //]]> </script></head><body><div id="package-header"><ul class="links" id="page-menu"><li><a href="src/XMonad-Actions-CycleWS.html">Source</a></li><li><a href="index.html">Contents</a></li><li><a href="doc-index.html">Index</a></li></ul><p class="caption">xmonad-contrib-0.9.2: Third party extensions for xmonad</p></div><div id="content"><div id="module-header"><table class="info"><tr><th>Portability</th><td>unportable</td></tr><tr><th>Stability</th><td>unstable</td></tr><tr><th>Maintainer</th><td>Joachim Breitner <mail@joachim-breitner.de></td></tr></table><p class="caption">XMonad.Actions.CycleWS</p></div><div id="table-of-contents"><p class="caption">Contents</p><ul><li><a href="#g:1">Usage </a></li><li><a href="#g:2">Moving between workspaces </a></li><li><a href="#g:3">Toggling the previous workspace </a></li><li><a href="#g:4">Moving between screens (xinerama) </a></li><li><a href="#g:5">Moving between workspaces, take two! </a></li><li><a href="#g:6">The mother-combinator </a></li></ul></div><div id="description"><p class="caption">Description</p><div class="doc"><p>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. </p><p>Note that this module now subsumes the functionality of the former <code>XMonad.Actions.RotView</code>. Former users of <code>rotView</code> can simply replace <code>rotView True</code> with <code>moveTo Next NonEmptyWS</code>, and so on. </p><p>If you want to exactly replicate the action of <code>rotView</code> (cycling through workspace in order lexicographically by tag, instead of in the order specified in the config), it can be implemented as: </p><pre> rotView b = do t <- findWorkspace getSortByTag (bToDir b) NonEmptyWS 1 windows . greedyView $ t where bToDir True = Next bToDir False = Prev </pre></div></div><div id="synopsis"><p id="control.syn" class="caption expander" onclick="toggleSection('syn')">Synopsis</p><ul id="section.syn" class="hide" onclick="toggleSection('syn')"><li class="src short"><a href="#v:nextWS">nextWS</a> :: X <a href="/usr/share/doc/ghc/html/libraries/ghc-prim-0.2.0.0/GHC-Unit.html#t:-40--41-">()</a></li><li class="src short"><a href="#v:prevWS">prevWS</a> :: X <a href="/usr/share/doc/ghc/html/libraries/ghc-prim-0.2.0.0/GHC-Unit.html#t:-40--41-">()</a></li><li class="src short"><a href="#v:shiftToNext">shiftToNext</a> :: X <a href="/usr/share/doc/ghc/html/libraries/ghc-prim-0.2.0.0/GHC-Unit.html#t:-40--41-">()</a></li><li class="src short"><a href="#v:shiftToPrev">shiftToPrev</a> :: X <a href="/usr/share/doc/ghc/html/libraries/ghc-prim-0.2.0.0/GHC-Unit.html#t:-40--41-">()</a></li><li class="src short"><a href="#v:toggleWS">toggleWS</a> :: X <a href="/usr/share/doc/ghc/html/libraries/ghc-prim-0.2.0.0/GHC-Unit.html#t:-40--41-">()</a></li><li class="src short"><a href="#v:toggleOrView">toggleOrView</a> :: WorkspaceId -> X <a href="/usr/share/doc/ghc/html/libraries/ghc-prim-0.2.0.0/GHC-Unit.html#t:-40--41-">()</a></li><li class="src short"><a href="#v:nextScreen">nextScreen</a> :: X <a href="/usr/share/doc/ghc/html/libraries/ghc-prim-0.2.0.0/GHC-Unit.html#t:-40--41-">()</a></li><li class="src short"><a href="#v:prevScreen">prevScreen</a> :: X <a href="/usr/share/doc/ghc/html/libraries/ghc-prim-0.2.0.0/GHC-Unit.html#t:-40--41-">()</a></li><li class="src short"><a href="#v:shiftNextScreen">shiftNextScreen</a> :: X <a href="/usr/share/doc/ghc/html/libraries/ghc-prim-0.2.0.0/GHC-Unit.html#t:-40--41-">()</a></li><li class="src short"><a href="#v:shiftPrevScreen">shiftPrevScreen</a> :: X <a href="/usr/share/doc/ghc/html/libraries/ghc-prim-0.2.0.0/GHC-Unit.html#t:-40--41-">()</a></li><li class="src short"><a href="#v:swapNextScreen">swapNextScreen</a> :: X <a href="/usr/share/doc/ghc/html/libraries/ghc-prim-0.2.0.0/GHC-Unit.html#t:-40--41-">()</a></li><li class="src short"><a href="#v:swapPrevScreen">swapPrevScreen</a> :: X <a href="/usr/share/doc/ghc/html/libraries/ghc-prim-0.2.0.0/GHC-Unit.html#t:-40--41-">()</a></li><li class="src short"><span class="keyword">data</span> <a href="#t:Direction1D">Direction1D</a> <ul class="subs"><li>= <a href="#v:Next">Next</a> </li><li>| <a href="#v:Prev">Prev</a> </li></ul></li><li class="src short"><span class="keyword">data</span> <a href="#t:WSType">WSType</a> <ul class="subs"><li>= <a href="#v:EmptyWS">EmptyWS</a> </li><li>| <a href="#v:NonEmptyWS">NonEmptyWS</a> </li><li>| <a href="#v:HiddenWS">HiddenWS</a> </li><li>| <a href="#v:HiddenNonEmptyWS">HiddenNonEmptyWS</a> </li><li>| <a href="#v:AnyWS">AnyWS</a> </li><li>| <a href="#v:WSIs">WSIs</a> (X (WindowSpace -> <a href="/usr/share/doc/ghc/html/libraries/base-4.3.1.0/Data-Bool.html#t:Bool">Bool</a>)) </li></ul></li><li class="src short"><a href="#v:shiftTo">shiftTo</a> :: <a href="XMonad-Actions-CycleWS.html#t:Direction1D">Direction1D</a> -> <a href="XMonad-Actions-CycleWS.html#t:WSType">WSType</a> -> X <a href="/usr/share/doc/ghc/html/libraries/ghc-prim-0.2.0.0/GHC-Unit.html#t:-40--41-">()</a></li><li class="src short"><a href="#v:moveTo">moveTo</a> :: <a href="XMonad-Actions-CycleWS.html#t:Direction1D">Direction1D</a> -> <a href="XMonad-Actions-CycleWS.html#t:WSType">WSType</a> -> X <a href="/usr/share/doc/ghc/html/libraries/ghc-prim-0.2.0.0/GHC-Unit.html#t:-40--41-">()</a></li><li class="src short"><a href="#v:findWorkspace">findWorkspace</a> :: X <a href="XMonad-Util-WorkspaceCompare.html#t:WorkspaceSort">WorkspaceSort</a> -> <a href="XMonad-Actions-CycleWS.html#t:Direction1D">Direction1D</a> -> <a href="XMonad-Actions-CycleWS.html#t:WSType">WSType</a> -> <a href="/usr/share/doc/ghc/html/libraries/base-4.3.1.0/Data-Int.html#t:Int">Int</a> -> X WorkspaceId</li><li class="src short"><a href="#v:toggleOrDoSkip">toggleOrDoSkip</a> :: [WorkspaceId] -> (WorkspaceId -> WindowSet -> WindowSet) -> WorkspaceId -> X <a href="/usr/share/doc/ghc/html/libraries/ghc-prim-0.2.0.0/GHC-Unit.html#t:-40--41-">()</a></li><li class="src short"><a href="#v:skipTags">skipTags</a> :: <a href="/usr/share/doc/ghc/html/libraries/base-4.3.1.0/Data-Eq.html#t:Eq">Eq</a> i => [Workspace i l a] -> [i] -> [Workspace i l a]</li></ul></div><div id="interface"><h1 id="g:1">Usage </h1><div class="doc"><p>You can use this module with the following in your <code>~/.xmonad/xmonad.hs</code> file: </p><pre> import XMonad.Actions.CycleWS -- a basic CycleWS setup , ((modm, xK_Down), nextWS) , ((modm, xK_Up), prevWS) , ((modm .|. shiftMask, xK_Down), shiftToNext) , ((modm .|. shiftMask, xK_Up), shiftToPrev) , ((modm, xK_Right), nextScreen) , ((modm, xK_Left), prevScreen) , ((modm .|. shiftMask, xK_Right), shiftNextScreen) , ((modm .|. shiftMask, xK_Left), shiftPrevScreen) , ((modm, xK_z), toggleWS) </pre><p>If you want to follow the moved window, you can use both actions: </p><pre> , ((modm .|. shiftMask, xK_Down), shiftToNext >> nextWS) , ((modm .|. shiftMask, xK_Up), shiftToPrev >> prevWS) </pre><p>You can also get fancier with <code><a href="XMonad-Actions-CycleWS.html#v:moveTo">moveTo</a></code>, <code><a href="XMonad-Actions-CycleWS.html#v:shiftTo">shiftTo</a></code>, and <code><a href="XMonad-Actions-CycleWS.html#v:findWorkspace">findWorkspace</a></code>. For example: </p><pre> , ((modm , xK_f), moveTo Next EmptyWS) -- find a free workspace , ((modm .|. controlMask, xK_Right), -- a crazy keybinding! do t <- findWorkspace getSortByXineramaRule Next NonEmptyWS 2 windows . view $ t ) </pre><p>For detailed instructions on editing your key bindings, see <a href="XMonad-Doc-Extending.html#Editing_key_bindings">XMonad.Doc.Extending</a>. </p></div><h1 id="g:2">Moving between workspaces </h1><div class="doc"><p>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. </p><p>All of the commands in this section cycle through workspaces in the order in which they are given in your config. </p></div><div class="top"><p class="src"><a name="v:nextWS" class="def">nextWS</a> :: X <a href="/usr/share/doc/ghc/html/libraries/ghc-prim-0.2.0.0/GHC-Unit.html#t:-40--41-">()</a><a href="src/XMonad-Actions-CycleWS.html#nextWS" class="link">Source</a></p><div class="doc"><p>Switch to the next workspace. </p></div></div><div class="top"><p class="src"><a name="v:prevWS" class="def">prevWS</a> :: X <a href="/usr/share/doc/ghc/html/libraries/ghc-prim-0.2.0.0/GHC-Unit.html#t:-40--41-">()</a><a href="src/XMonad-Actions-CycleWS.html#prevWS" class="link">Source</a></p><div class="doc"><p>Switch to the previous workspace. </p></div></div><div class="top"><p class="src"><a name="v:shiftToNext" class="def">shiftToNext</a> :: X <a href="/usr/share/doc/ghc/html/libraries/ghc-prim-0.2.0.0/GHC-Unit.html#t:-40--41-">()</a><a href="src/XMonad-Actions-CycleWS.html#shiftToNext" class="link">Source</a></p><div class="doc"><p>Move the focused window to the next workspace. </p></div></div><div class="top"><p class="src"><a name="v:shiftToPrev" class="def">shiftToPrev</a> :: X <a href="/usr/share/doc/ghc/html/libraries/ghc-prim-0.2.0.0/GHC-Unit.html#t:-40--41-">()</a><a href="src/XMonad-Actions-CycleWS.html#shiftToPrev" class="link">Source</a></p><div class="doc"><p>Move the focused window to the previous workspace. </p></div></div><h1 id="g:3">Toggling the previous workspace </h1><div class="doc empty"> </div><div class="top"><p class="src"><a name="v:toggleWS" class="def">toggleWS</a> :: X <a href="/usr/share/doc/ghc/html/libraries/ghc-prim-0.2.0.0/GHC-Unit.html#t:-40--41-">()</a><a href="src/XMonad-Actions-CycleWS.html#toggleWS" class="link">Source</a></p><div class="doc"><p>Toggle to the workspace displayed previously. </p></div></div><div class="top"><p class="src"><a name="v:toggleOrView" class="def">toggleOrView</a> :: WorkspaceId -> X <a href="/usr/share/doc/ghc/html/libraries/ghc-prim-0.2.0.0/GHC-Unit.html#t:-40--41-">()</a><a href="src/XMonad-Actions-CycleWS.html#toggleOrView" class="link">Source</a></p><div class="doc"><p><code>greedyView</code> a workspace, or if already there, view the previously displayed workspace ala weechat. Change <code>greedyView</code> to <code>toggleOrView</code> in your workspace bindings as in the <code>view</code> faq at <a href="http://haskell.org/haskellwiki/Xmonad/Frequently_asked_questions">http://haskell.org/haskellwiki/Xmonad/Frequently_asked_questions</a>. For more flexibility see <code><a href="XMonad-Actions-CycleWS.html#v:toggleOrDoSkip">toggleOrDoSkip</a></code>. </p></div></div><h1 id="g:4">Moving between screens (xinerama) </h1><div class="top"><p class="src"><a name="v:nextScreen" class="def">nextScreen</a> :: X <a href="/usr/share/doc/ghc/html/libraries/ghc-prim-0.2.0.0/GHC-Unit.html#t:-40--41-">()</a><a href="src/XMonad-Actions-CycleWS.html#nextScreen" class="link">Source</a></p><div class="doc"><p>View next screen </p></div></div><div class="top"><p class="src"><a name="v:prevScreen" class="def">prevScreen</a> :: X <a href="/usr/share/doc/ghc/html/libraries/ghc-prim-0.2.0.0/GHC-Unit.html#t:-40--41-">()</a><a href="src/XMonad-Actions-CycleWS.html#prevScreen" class="link">Source</a></p><div class="doc"><p>View prev screen </p></div></div><div class="top"><p class="src"><a name="v:shiftNextScreen" class="def">shiftNextScreen</a> :: X <a href="/usr/share/doc/ghc/html/libraries/ghc-prim-0.2.0.0/GHC-Unit.html#t:-40--41-">()</a><a href="src/XMonad-Actions-CycleWS.html#shiftNextScreen" class="link">Source</a></p><div class="doc"><p>Move focused window to workspace on next screen </p></div></div><div class="top"><p class="src"><a name="v:shiftPrevScreen" class="def">shiftPrevScreen</a> :: X <a href="/usr/share/doc/ghc/html/libraries/ghc-prim-0.2.0.0/GHC-Unit.html#t:-40--41-">()</a><a href="src/XMonad-Actions-CycleWS.html#shiftPrevScreen" class="link">Source</a></p><div class="doc"><p>Move focused window to workspace on prev screen </p></div></div><div class="top"><p class="src"><a name="v:swapNextScreen" class="def">swapNextScreen</a> :: X <a href="/usr/share/doc/ghc/html/libraries/ghc-prim-0.2.0.0/GHC-Unit.html#t:-40--41-">()</a><a href="src/XMonad-Actions-CycleWS.html#swapNextScreen" class="link">Source</a></p><div class="doc"><p>Swap current screen with next screen </p></div></div><div class="top"><p class="src"><a name="v:swapPrevScreen" class="def">swapPrevScreen</a> :: X <a href="/usr/share/doc/ghc/html/libraries/ghc-prim-0.2.0.0/GHC-Unit.html#t:-40--41-">()</a><a href="src/XMonad-Actions-CycleWS.html#swapPrevScreen" class="link">Source</a></p><div class="doc"><p>Swap current screen with previous screen </p></div></div><h1 id="g:5">Moving between workspaces, take two! </h1><div class="doc"><p>A few more general commands are also provided, which allow cycling through subsets of workspaces. </p><p>For example, </p><pre> moveTo Next EmptyWS </pre><p>will move to the first available workspace with no windows, and </p><pre> shiftTo Prev (WSIs $ return (('p' `elem`) . tag)) </pre><p>will move the focused window backwards to the first workspace containing the letter <code>p</code> in its name. =) </p></div><div class="top"><p class="src"><span class="keyword">data</span> <a name="t:Direction1D" class="def">Direction1D</a> <a href="src/XMonad-Util-Types.html#Direction1D" class="link">Source</a></p><div class="doc"><p>One-dimensional directions: </p></div><div class="subs constructors"><p class="caption">Constructors</p><table><tr><td class="src"><a name="v:Next" class="def">Next</a></td><td class="doc empty"> </td></tr><tr><td class="src"><a name="v:Prev" class="def">Prev</a></td><td class="doc empty"> </td></tr></table></div><div class="subs instances"><p id="control.i:Direction1D" class="caption collapser" onclick="toggleSection('i:Direction1D')">Instances</p><div id="section.i:Direction1D" class="show"><table><tr><td class="src"><a href="/usr/share/doc/ghc/html/libraries/base-4.3.1.0/Data-Eq.html#t:Eq">Eq</a> <a href="XMonad-Actions-CycleWS.html#t:Direction1D">Direction1D</a></td><td class="doc empty"> </td></tr><tr><td class="src"><a href="/usr/share/doc/ghc/html/libraries/base-4.3.1.0/Text-Read.html#t:Read">Read</a> <a href="XMonad-Actions-CycleWS.html#t:Direction1D">Direction1D</a></td><td class="doc empty"> </td></tr><tr><td class="src"><a href="/usr/share/doc/ghc/html/libraries/base-4.3.1.0/Text-Show.html#t:Show">Show</a> <a href="XMonad-Actions-CycleWS.html#t:Direction1D">Direction1D</a></td><td class="doc empty"> </td></tr><tr><td class="src"><a href="/usr/share/doc/ghc/html/libraries/base-4.3.1.0/Data-Typeable.html#t:Typeable">Typeable</a> <a href="XMonad-Actions-CycleWS.html#t:Direction1D">Direction1D</a></td><td class="doc empty"> </td></tr></table></div></div></div><div class="top"><p class="src"><span class="keyword">data</span> <a name="t:WSType" class="def">WSType</a> <a href="src/XMonad-Actions-CycleWS.html#WSType" class="link">Source</a></p><div class="doc"><p>What type of workspaces should be included in the cycle? </p></div><div class="subs constructors"><p class="caption">Constructors</p><table><tr><td class="src"><a name="v:EmptyWS" class="def">EmptyWS</a></td><td class="doc"><p>cycle through empty workspaces </p></td></tr><tr><td class="src"><a name="v:NonEmptyWS" class="def">NonEmptyWS</a></td><td class="doc"><p>cycle through non-empty workspaces </p></td></tr><tr><td class="src"><a name="v:HiddenWS" class="def">HiddenWS</a></td><td class="doc"><p>cycle through non-visible workspaces </p></td></tr><tr><td class="src"><a name="v:HiddenNonEmptyWS" class="def">HiddenNonEmptyWS</a></td><td class="doc"><p>cycle through non-empty non-visible workspaces </p></td></tr><tr><td class="src"><a name="v:AnyWS" class="def">AnyWS</a></td><td class="doc"><p>cycle through all workspaces </p></td></tr><tr><td class="src"><a name="v:WSIs" class="def">WSIs</a> (X (WindowSpace -> <a href="/usr/share/doc/ghc/html/libraries/base-4.3.1.0/Data-Bool.html#t:Bool">Bool</a>))</td><td class="doc"><p>cycle through workspaces satisfying an arbitrary predicate </p></td></tr></table></div></div><div class="top"><p class="src"><a name="v:shiftTo" class="def">shiftTo</a> :: <a href="XMonad-Actions-CycleWS.html#t:Direction1D">Direction1D</a> -> <a href="XMonad-Actions-CycleWS.html#t:WSType">WSType</a> -> X <a href="/usr/share/doc/ghc/html/libraries/ghc-prim-0.2.0.0/GHC-Unit.html#t:-40--41-">()</a><a href="src/XMonad-Actions-CycleWS.html#shiftTo" class="link">Source</a></p><div class="doc"><p>Move the currently focused window to the next workspace in the given direction that satisfies the given condition. </p></div></div><div class="top"><p class="src"><a name="v:moveTo" class="def">moveTo</a> :: <a href="XMonad-Actions-CycleWS.html#t:Direction1D">Direction1D</a> -> <a href="XMonad-Actions-CycleWS.html#t:WSType">WSType</a> -> X <a href="/usr/share/doc/ghc/html/libraries/ghc-prim-0.2.0.0/GHC-Unit.html#t:-40--41-">()</a><a href="src/XMonad-Actions-CycleWS.html#moveTo" class="link">Source</a></p><div class="doc"><p>View the next workspace in the given direction that satisfies the given condition. </p></div></div><h1 id="g:6">The mother-combinator </h1><div class="top"><p class="src"><a name="v:findWorkspace" class="def">findWorkspace</a> :: X <a href="XMonad-Util-WorkspaceCompare.html#t:WorkspaceSort">WorkspaceSort</a> -> <a href="XMonad-Actions-CycleWS.html#t:Direction1D">Direction1D</a> -> <a href="XMonad-Actions-CycleWS.html#t:WSType">WSType</a> -> <a href="/usr/share/doc/ghc/html/libraries/base-4.3.1.0/Data-Int.html#t:Int">Int</a> -> X WorkspaceId<a href="src/XMonad-Actions-CycleWS.html#findWorkspace" class="link">Source</a></p><div class="doc"><p>Given a function <code>s</code> to sort workspaces, a direction <code>dir</code>, a predicate <code>p</code> on workspaces, and an integer <code>n</code>, find the tag of the workspace which is <code>n</code> away from the current workspace in direction <code>dir</code> (wrapping around if necessary), among those workspaces, sorted by <code>s</code>, which satisfy <code>p</code>. </p><p>For some useful workspace sorting functions, see <a href="XMonad-Util-WorkspaceCompare.html">XMonad.Util.WorkspaceCompare</a>. </p><p>For ideas of what to do with a workspace tag once obtained, note that <code><a href="XMonad-Actions-CycleWS.html#v:moveTo">moveTo</a></code> and <code><a href="XMonad-Actions-CycleWS.html#v:shiftTo">shiftTo</a></code> are implemented by applying <code>(>>= (windows . greedyView))</code> and <code>(>>= (windows . shift))</code>, respectively, to the output of <code><a href="XMonad-Actions-CycleWS.html#v:findWorkspace">findWorkspace</a></code>. </p></div></div><div class="top"><p class="src"><a name="v:toggleOrDoSkip" class="def">toggleOrDoSkip</a> :: [WorkspaceId] -> (WorkspaceId -> WindowSet -> WindowSet) -> WorkspaceId -> X <a href="/usr/share/doc/ghc/html/libraries/ghc-prim-0.2.0.0/GHC-Unit.html#t:-40--41-">()</a><a href="src/XMonad-Actions-CycleWS.html#toggleOrDoSkip" class="link">Source</a></p><div class="doc"><p>Allows ignoring listed workspace tags (such as scratchpad's "NSP") while finding the previously displayed workspace, or choice of different actions, like view, shift, etc. For example: </p><pre> import qualified XMonad.StackSet as W import XMonad.Actions.CycleWS -- toggleOrView for people who prefer view to greedyView toggleOrView' = toggleOrDoSkip [] W.view -- toggleOrView ignoring scratchpad and named scratchpad workspace toggleOrViewNoSP = toggleOrDoSkip ["NSP"] W.greedyView </pre></div></div><div class="top"><p class="src"><a name="v:skipTags" class="def">skipTags</a> :: <a href="/usr/share/doc/ghc/html/libraries/base-4.3.1.0/Data-Eq.html#t:Eq">Eq</a> i => [Workspace i l a] -> [i] -> [Workspace i l a]<a href="src/XMonad-Actions-CycleWS.html#skipTags" class="link">Source</a></p><div class="doc"><p>List difference (<code>\\</code>) for workspaces and tags. Removes workspaces matching listed tags from the given workspace list. </p></div></div></div></div><div id="footer"><p>Produced by <a href="http://www.haskell.org/haddock/">Haddock</a> version 2.9.2</p></div></body></html>