diff options
author | Andrea Rossato <andrea.rossato@unibz.it> | 2007-08-21 08:11:32 +0200 |
---|---|---|
committer | Andrea Rossato <andrea.rossato@unibz.it> | 2007-08-21 08:11:32 +0200 |
commit | 1abf9a13725974be5a14e97098c76be2bc4fadf5 (patch) | |
tree | b64b25bd43e1de37345e3bd7611e5b3fe100ed46 | |
parent | 5edbb125958df0adadd354fae48877d36086abd5 (diff) | |
download | XMonadContrib-1abf9a13725974be5a14e97098c76be2bc4fadf5.tar.gz XMonadContrib-1abf9a13725974be5a14e97098c76be2bc4fadf5.tar.xz XMonadContrib-1abf9a13725974be5a14e97098c76be2bc4fadf5.zip |
CycleWS: a couple of simple functions to cycle between workspaces
darcs-hash:20070821061132-32816-d93b765a58cb111bb661b4cb561f1b5a50a3d726.gz
-rw-r--r-- | CycleWS.hs | 51 |
1 files changed, 51 insertions, 0 deletions
diff --git a/CycleWS.hs b/CycleWS.hs new file mode 100644 index 0000000..a3b9f19 --- /dev/null +++ b/CycleWS.hs @@ -0,0 +1,51 @@ +----------------------------------------------------------------------------- +-- | +-- Module : XMonadContrib.CycleWS +-- Copyright : (C) 2007 Andrea Rossato +-- License : BSD3 +-- +-- Maintainer : andrea.rossato@unibz.it +-- Stability : unstable +-- Portability : unportable +-- +-- A module to cycle between Workspaces +-- +----------------------------------------------------------------------------- + +module XMonadContrib.CycleWS ( + -- * Usage + -- $usage + nextWS + , prevWS + ) where + +import XMonad +import Operations +import qualified StackSet as W +import {-# SOURCE #-} Config (workspaces) +import Data.List + +-- $usage +-- Import this module in Config.hs: +-- +-- > import XMonadContrib.CycleWS +-- +-- And add, in you key bindings: +-- +-- > , ((modMask , xK_comma ), prevWS ) +-- > , ((modMask , xK_period), nextWS ) + +nextWS, prevWS :: X () +nextWS = withWindowSet $ \s -> view (workspaces !! (setWS s N)) +prevWS = withWindowSet $ \s -> view (workspaces !! (setWS s P)) + +data Dir = P | N deriving Eq +setWS :: WindowSet -> Dir -> Int +setWS s d + | d == N && cur == (lw - 1) = 0 + | d == N = cur + 1 + | d == P && cur == 0 = lw - 1 + | otherwise = cur - 1 + where + cur = maybe 0 id $ elemIndex (W.tag (W.workspace ((W.current s)))) workspaces + lw = length workspaces |