xmonad-contrib/RotView.hs
Miikka Koskinen 4b7c97d96b Make RotView compile.
As I'm not a Xinerama user, I'm not sure if rotView should consider only
hidden workspaces or also visible but not focused workspaces. I thought hidden
workspaces only would be more logical.
2007-05-22 07:53:38 +00:00

32 lines
940 B
Haskell

module XMonadContrib.RotView ( rotView ) where
-- Provides bindings to cycle through non-empty workspaces.
-- To use:
-- import XMonadContrib.RotView
-- , ((modMask .|. shiftMask, xK_Right), rotView True)
-- , ((modMask .|. shiftMask, xK_Left), rotView False)
import Control.Monad.State ( gets )
import Data.List ( sortBy )
import Data.Maybe ( listToMaybe )
import XMonad
import StackSet
import qualified Operations as O
rotView :: Bool -> X ()
rotView b = do
ws <- gets windowset
let m = tag . workspace . current $ ws
sortWs = sortBy (\x y -> compare (tag x) (tag y))
pivoted = uncurry (flip (++)) . span ((< m) . tag) . sortWs . hidden $ ws
nextws = listToMaybe . filter (not.isEmpty) . (if b then id else reverse) $ pivoted
whenJust nextws (O.view . tag)
isEmpty :: Workspace i a -> Bool
isEmpty ws = case stack ws of
Empty -> True
_ -> False