nixos-config/system/desktop/home-manager/xmonad/Memo.hs

38 lines
1.2 KiB
Haskell
Raw Normal View History

{-# LANGUAGE DeriveDataTypeable #-}
{-| A hacky module to cycle through a list of
rectangles, I'm using this to place a floating window somehwere
when it is in my way -}
module Memo where
import XMonad.Config.Prime
import qualified XMonad.StackSet as W
import qualified XMonad.Util.ExtensibleState as ES
newtype MemoStorage =
MemoStorage [W.RationalRect]
deriving (Typeable)
-- (RationalRect x y height width)
instance ExtensionClass MemoStorage where
initialValue =
MemoStorage
(cycle
[ (W.RationalRect 0.0 0.0 0.4 0.4) -- oben links
, (W.RationalRect 0.6 0.6 0.4 0.4) -- unten rechts
, (W.RationalRect 0.6 0.0 0.4 0.4) -- oben rechts
, (W.RationalRect 0.0 0.6 0.4 0.4) -- unten links
, (W.RationalRect 0.25 0.00 0.4 0.4) -- oben mitte
, (W.RationalRect 0.25 0.60 0.4 0.4) -- unten mitte
, (W.RationalRect 0.00 0.25 0.4 0.4) -- links mitte
, (W.RationalRect 0.60 0.25 0.4 0.4) -- rechts mitte
])
nextRectangle :: X W.RationalRect
nextRectangle = do
MemoStorage next <- ES.get :: X MemoStorage
ES.modify (\(MemoStorage (_:xs)) -> MemoStorage xs)
return (head next)