nix-config/modules/home-manager/desktop-xmonad/xmonad/lib/Layouts.hs

125 lines
3.9 KiB
Haskell
Raw Normal View History

2022-01-18 09:32:55 +01:00
{-# LANGUAGE FlexibleContexts #-}
{-# OPTIONS_GHC -fno-warn-missing-signatures #-}
module Layouts (myLayoutHook) where
import Text.Printf (printf)
import XMonad.Config (def)
import XMonad.Core ( LayoutClass )
import XMonad.Hooks.ManageDocks (avoidStruts)
import XMonad.Layout ( Mirror (Mirror) , (|||) )
import XMonad.Layout.PerWorkspace ( onWorkspaces )
import XMonad.Layout.LayoutModifier ( ModifiedLayout , LayoutModifier )
import XMonad.Layout.BoringWindows ( boringWindows )
import XMonad.Layout.Decoration ( Theme , DefaultShrinker , Decoration )
import XMonad.Layout.Maximize ( maximizeWithPadding )
import XMonad.Layout.Minimize ( minimize )
import XMonad.Layout.MultiToggle ( mkToggle , single )
import XMonad.Layout.Renamed ( renamed, Rename (Replace) )
import XMonad.Layout.NoBorders ( smartBorders )
import XMonad.Layout.ResizableTile ( ResizableTall (..) )
import XMonad.Layout.Spacing ( Spacing , spacingRaw , Border (..) )
import XMonad.Layout.WindowNavigation ( windowNavigation )
import XMonad.Layout.SubLayouts ( subLayout , Sublayout )
import XMonad.Layout.Simplest ( Simplest(Simplest) )
import XMonad.Layout.Grid ( Grid(Grid) )
import XMonad.Layout.Reflect
( REFLECTX (REFLECTX)
, REFLECTY (REFLECTY)
)
import XMonad.Layout.Tabbed
( shrinkText
, addTabs
, TabbedDecoration
)
import qualified XMonad.Layout.Tabbed as T
( activeColor
, inactiveColor
, activeBorderColor
, inactiveBorderColor
, urgentColor
, activeTextColor
, inactiveTextColor
, urgentTextColor
, fontName
)
import XMonad.Layout.PositionStoreFloat (positionStoreFloat)
import XMonad.Layout.NoFrillsDecoration (noFrillsDeco)
import XMonad.Layout.BorderResize (borderResize)
import HostConfig
( FontConfig
, fontName
, fontSize
, ColorConfig
, fgColor
, selFgColor
, bgColor
, selColor
, inactiveColor
, inactiveBorderColor
, urgentColor
, colorConfig
, fontConfig
)
named :: String -> l a -> ModifiedLayout Rename l a
named x = renamed [Replace x]
myLayoutHook = commonMods mainLayouts
where
tileMods = mkToggle (single REFLECTX) . mkToggle (single REFLECTY)
. smartBorders
. windowNavigation . mySubTabbed theme
. spaces
commonMods = avoidStruts
. maximizeWithPadding 0
. minimize
. boringWindows
tLayouts = tileMods $ named "tall" tall ||| named "mtall" mtall
mainLayouts = tLayouts ||| floating theme
floating theme = named "float" . floatingDeco . borderResize $ positionStoreFloat
where
floatingDeco = noFrillsDeco shrinkText theme
mySubTabbed
:: (Eq a, LayoutModifier (Sublayout Simplest) a, LayoutClass l a)
=> Theme
-> l a
-> ModifiedLayout
(Decoration TabbedDecoration DefaultShrinker)
(ModifiedLayout (Sublayout Simplest) l)
a
mySubTabbed theme x = addTabs shrinkText theme $ subLayout [] Simplest x
spaces :: l a -> ModifiedLayout Spacing l a
spaces = spacingRaw False b False b False
where
b = Border defSpacing defSpacing defSpacing defSpacing
defSpacing = 5
tall :: ResizableTall a
tall = ResizableTall 1 (3/100) (1/2) []
mtall :: Mirror ResizableTall a
mtall = Mirror tall
theme :: Theme
theme = def
{ T.activeColor = selColor colorConfig
, T.activeBorderColor = inactiveColor colorConfig
, T.activeTextColor = selFgColor colorConfig
, T.inactiveColor = bgColor colorConfig
, T.inactiveBorderColor = inactiveBorderColor colorConfig
, T.inactiveTextColor = fgColor colorConfig
, T.urgentColor = urgentColor colorConfig
, T.urgentTextColor = urgentColor colorConfig
, T.fontName = printf "xft:%s:size=%d" (fontName fontConfig) (fontSize fontConfig)
}