Skip to content

Instantly share code, notes, and snippets.

@anekos
Created June 10, 2012 11:49
Show Gist options
  • Select an option

  • Save anekos/2905124 to your computer and use it in GitHub Desktop.

Select an option

Save anekos/2905124 to your computer and use it in GitHub Desktop.
四畳半レイアウト for XMonad
{-# LANGUAGE FlexibleInstances, MultiParamTypeClasses #-}
-----------------------------------------------------------------------------
-- |
-- Module : XMonad.Layout.YojouHan
-- Copyright : anekos 2012
-- License : BSD3
--
-- Maintainer : anekos
-- Stability : unstable
-- Portability : unportable
--
-- Japanese tatami style layout.
-----------------------------------------------------------------------------
module XMonad.Layout.YojouHan (
-- * Usage
-- $usage
YojouHan(..)
) where
import XMonad
import XMonad.StackSet (integrate)
import Graphics.X11 (Rectangle(..))
-- $usage
--
-- > import XMonad.Layout.YojouHan
--
-- > layoutHook = YojouHan ||| Tall 1 (3/100) (1/2) ||| Full ...
--
data YojouHan a = YojouHan deriving ( Read, Show )
instance LayoutClass YojouHan Window where
doLayout YojouHan r s = do let layout = yojouHanLayout r $ integrate s
return (layout, Nothing)
yojouHanLayout :: Rectangle -> [a] -> [(a, Rectangle)]
yojouHanLayout (Rectangle x y w h) ws = zip ws rs
where
rs = [ (Rectangle x y (t w) (o h))
, (Rectangle (x + t w) y (o w) (t h))
, (Rectangle (x + o w) (y + t h) (t w) (o h))
, (Rectangle x (y + o h) (o w) (t h))
, (Rectangle (x + o w) (y + o h) (o w) (o h)) ]
t x = fromIntegral $ x `div` 3 * 2
o x = fromIntegral $ x `div` 3
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment