mirror of
https://github.com/xmonad/xmonad-contrib.git
synced 2025-05-19 03:20:21 -07:00
46 lines
1.4 KiB
Haskell
46 lines
1.4 KiB
Haskell
-----------------------------------------------------------------------------
|
|
-- |
|
|
-- Module : XMonadContrib.RotView
|
|
-- Copyright : (c) David Roundy <droundy@darcs.net>
|
|
-- License : BSD3-style (see LICENSE)
|
|
--
|
|
-- Maintainer : David Roundy <droundy@darcs.net>
|
|
-- Stability : unstable
|
|
-- Portability : unportable
|
|
--
|
|
-- Provides bindings to cycle through non-empty workspaces.
|
|
--
|
|
-----------------------------------------------------------------------------
|
|
|
|
module XMonadContrib.RotView (
|
|
-- * Usage
|
|
-- $usage
|
|
rotView
|
|
) where
|
|
|
|
import Control.Monad.State ( gets )
|
|
import Data.List ( sortBy )
|
|
import Data.Maybe ( listToMaybe, isJust )
|
|
import Data.Ord ( comparing )
|
|
|
|
import XMonad
|
|
import StackSet hiding (filter)
|
|
import qualified Operations as O
|
|
|
|
-- $usage
|
|
-- You can use this module with the following in your Config.hs file:
|
|
--
|
|
-- > import XMonadContrib.RotView
|
|
--
|
|
-- > , ((modMask .|. shiftMask, xK_Right), rotView True)
|
|
-- > , ((modMask .|. shiftMask, xK_Left), rotView False)
|
|
|
|
rotView :: Bool -> X ()
|
|
rotView b = do
|
|
ws <- gets windowset
|
|
let m = tag . workspace . current $ ws
|
|
sortWs = sortBy (comparing tag)
|
|
pivoted = uncurry (flip (++)) . span ((< m) . tag) . sortWs . hidden $ ws
|
|
nextws = listToMaybe . filter (isJust . stack) . (if b then id else reverse) $ pivoted
|
|
whenJust nextws (O.view . tag)
|