add more layouts

This commit is contained in:
Leon Kowarschick 2020-05-18 14:23:16 +02:00
parent 5053af3246
commit b0e1ffdee5

View file

@ -1,3 +1,5 @@
{-# LANGUAGE MultiParamTypeClasses #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE FlexibleContexts #-} {-# LANGUAGE FlexibleContexts #-}
{-# Language ScopedTypeVariables, LambdaCase #-} {-# Language ScopedTypeVariables, LambdaCase #-}
{-# OPTIONS_GHC -fno-warn-missing-signatures -fno-warn-unused-binds #-} {-# OPTIONS_GHC -fno-warn-missing-signatures -fno-warn-unused-binds #-}
@ -8,6 +10,9 @@ module Config (main) where
import Control.Concurrent import Control.Concurrent
import Control.Exception ( catch , SomeException) import Control.Exception ( catch , SomeException)
import Control.Monad ( filterM ) import Control.Monad ( filterM )
import Control.Arrow ( second
, (***)
)
import Data.List ( isPrefixOf , isSuffixOf) import Data.List ( isPrefixOf , isSuffixOf)
import System.Exit (exitSuccess) import System.Exit (exitSuccess)
@ -35,6 +40,7 @@ import XMonad.Layout.LayoutHints
import XMonad.Layout.MouseResizableTile import XMonad.Layout.MouseResizableTile
import XMonad.Layout.NoBorders import XMonad.Layout.NoBorders
import XMonad.Layout.Renamed (renamed, Rename(Replace)) import XMonad.Layout.Renamed (renamed, Rename(Replace))
import qualified XMonad.Layout.MultiColumns as MultiCol
import XMonad.Layout.ResizableTile import XMonad.Layout.ResizableTile
import XMonad.Layout.Simplest import XMonad.Layout.Simplest
import XMonad.Layout.Spacing (spacingRaw, Border(..), toggleWindowSpacingEnabled) import XMonad.Layout.Spacing (spacingRaw, Border(..), toggleWindowSpacingEnabled)
@ -42,7 +48,12 @@ import XMonad.Layout.SubLayouts
import XMonad.Layout.Tabbed import XMonad.Layout.Tabbed
import XMonad.Layout.WindowNavigation ( windowNavigation ) import XMonad.Layout.WindowNavigation ( windowNavigation )
import XMonad.Layout.ZoomRow import XMonad.Layout.ZoomRow
import XMonad.Util.EZConfig ( additionalKeysP , removeKeysP , checkKeymap) import XMonad.Layout.ThreeColumns
import XMonad.Util.EZConfig ( additionalKeysP
, removeKeysP
, checkKeymap
, additionalMouseBindings
)
import XMonad.Util.NamedScratchpad import XMonad.Util.NamedScratchpad
import XMonad.Util.Run import XMonad.Util.Run
import XMonad.Util.SpawnOnce (spawnOnce) import XMonad.Util.SpawnOnce (spawnOnce)
@ -129,8 +140,8 @@ myTabTheme = def
-- layoutHints . -- layoutHints .
myLayout = -- avoidStruts myLayout = avoidStruts
smartBorders $ smartBorders
$ MTog.mkToggle1 MTog.FULL $ MTog.mkToggle1 MTog.FULL
$ ToggleLayouts.toggleLayouts resizableTabbedLayout $ ToggleLayouts.toggleLayouts resizableTabbedLayout
$ layoutHintsToCenter $ layoutHintsToCenter
@ -139,9 +150,11 @@ myLayout = -- avoidStruts
layouts =((rename "Tall" $ onlySpacing $ mouseResizableTile {draggerType = dragger}) layouts =((rename "Tall" $ onlySpacing $ mouseResizableTile {draggerType = dragger})
||| (rename "Horizon" $ onlySpacing $ mouseResizableTileMirrored {draggerType = dragger}) ||| (rename "Horizon" $ onlySpacing $ mouseResizableTileMirrored {draggerType = dragger})
||| (rename "BSP" $ spacingAndGaps $ borderResize $ emptyBSP) ||| (rename "BSP" $ spacingAndGaps $ borderResize $ emptyBSP)
||| (rename "TabbedRow" $ makeTabbed $ spacingAndGaps $ zoomRow) ||| (rename "FL ThreeCol" $ makeTabbed $ spacingAndGaps $ Mirror $ Flip $ ThreeColMid 1 (3/100) (1/2))
||| (rename "TabbedGrid" $ makeTabbed $ spacingAndGaps $ Grid False)) ||| (rename "ThreeCol" $ makeTabbed $ spacingAndGaps $ ThreeCol 1 (3/100) (1/2))
-- ||| (rename "threeCol" $ spacingAndGaps $ ThreeColMid 1 (3/100) (1/2)) ||| (rename "TabbedRow" $ makeTabbed $ spacingAndGaps $ zoomRow))
-- ||| (rename "MultiCol" $ spacingAndGaps $ Mirror $ MultiCol.multiCol [1] 3 0.01 0.5)
-- ||| (rename "TabbedGrid" $ makeTabbed $ spacingAndGaps $ Grid False))
-- ||| (rename "spiral" $ spacingAndGaps $ spiral (9/21)) -- ||| (rename "spiral" $ spacingAndGaps $ spiral (9/21))
rename n = renamed [Replace n] rename n = renamed [Replace n]
@ -158,6 +171,17 @@ myLayout = -- avoidStruts
-- transform a layout into supporting tabs -- transform a layout into supporting tabs
makeTabbed layout = BoringWindows.boringWindows . windowNavigation . addTabs shrinkText myTabTheme $ subLayout [] Simplest $ layout makeTabbed layout = BoringWindows.boringWindows . windowNavigation . addTabs shrinkText myTabTheme $ subLayout [] Simplest $ layout
-- | Flip a layout, compute its 180 degree rotated form.
newtype Flip l a = Flip (l a) deriving (Show, Read)
instance LayoutClass l a => LayoutClass (Flip l) a where
handleMessage (Flip l) = fmap (fmap Flip) . handleMessage l
description (Flip l) = "Flip " ++ description l
runLayout (W.Workspace i (Flip l) ms) r = (map (second flipRect) *** fmap Flip) <$> runLayout (W.Workspace i l ms) (flipRect r)
where screenWidth = fromIntegral $ rect_width r
flipRect (Rectangle rx ry rw rh) = Rectangle (screenWidth - rx - (fromIntegral rw)) ry rw rh
-- }}} -- }}}
-- Startuphook ----------------------------- {{{ -- Startuphook ----------------------------- {{{
@ -204,6 +228,8 @@ myKeys =
, ("M--", sendMessage zoomOut) , ("M--", sendMessage zoomOut)
, ("M-#", sendMessage zoomReset) , ("M-#", sendMessage zoomReset)
, ("M-S-<Space>", for_ [1..6 :: Int] $ \_ -> sendMessage $ NextLayout)
-- Tabs -- Tabs
, ("M-j", ifLayoutName ("Tabbed" `isPrefixOf`) (BoringWindows.focusDown) (windows W.focusDown)) , ("M-j", ifLayoutName ("Tabbed" `isPrefixOf`) (BoringWindows.focusDown) (windows W.focusDown))
@ -379,7 +405,9 @@ main = do
-- create polybarLogHooks for every monitor and combine them using the <+> monoid instance -- create polybarLogHooks for every monitor and combine them using the <+> monoid instance
let polybarLogHooks = composeAll $ map polybarLogHook monitorIndices let polybarLogHooks = composeAll $ map polybarLogHook monitorIndices
let myConfig = Desktop.desktopConfig let myConfig = flip additionalKeysP myKeys
. flip removeKeysP removedKeys
$ Desktop.desktopConfig
{ terminal = myTerminal { terminal = myTerminal
, workspaces = if useSharedWorkspaces , workspaces = if useSharedWorkspaces
then (map show [1..9 :: Int]) ++ ["NSP"] then (map show [1..9 :: Int]) ++ ["NSP"]
@ -394,7 +422,7 @@ main = do
, normalBorderColor = "#282828" , normalBorderColor = "#282828"
, handleEventHook = handleEventHook Desktop.desktopConfig , handleEventHook = handleEventHook Desktop.desktopConfig
--, handleEventHook = minimizeEventHook <+> handleEventHook def <+> hintsEventHook -- <+> Ewmh.fullscreenEventHook --, handleEventHook = minimizeEventHook <+> handleEventHook def <+> hintsEventHook -- <+> Ewmh.fullscreenEventHook
} `removeKeysP` removedKeys `additionalKeysP` myKeys }