Tabs are real!

This commit is contained in:
Leon Kowarschick 2020-05-12 13:02:54 +02:00
parent b337ce85db
commit 6980f156c3
2 changed files with 42 additions and 28 deletions

View file

@ -1,6 +1,4 @@
{-# LANGUAGE FlexibleContexts #-} {-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE MultiParamTypeClasses #-}
{-# LANGUAGE TypeSynonymInstances #-}
{-# 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 #-}
-- Imports -------------------------------------------------------- {{{ -- Imports -------------------------------------------------------- {{{
@ -45,10 +43,8 @@ import XMonad.Layout.NoBorders
import XMonad.Layout.Renamed (renamed, Rename(Replace)) import XMonad.Layout.Renamed (renamed, Rename(Replace))
import XMonad.Layout.ResizableTile import XMonad.Layout.ResizableTile
import XMonad.Layout.Spacing (spacingRaw, Border(..), toggleWindowSpacingEnabled) import XMonad.Layout.Spacing (spacingRaw, Border(..), toggleWindowSpacingEnabled)
import XMonad.Layout.ToggleLayouts import qualified XMonad.Layout.ToggleLayouts as ToggleLayouts
import XMonad.Layout.ZoomRow import XMonad.Layout.ZoomRow
import XMonad.Layout.MultiToggle
import XMonad.Layout.MultiToggle.Instances
import XMonad.Util.EZConfig ( additionalKeysP import XMonad.Util.EZConfig ( additionalKeysP
, removeKeysP , removeKeysP
, checkKeymap , checkKeymap
@ -129,30 +125,30 @@ aqua = "#8ec07c"
myTabTheme = def myTabTheme = def
{ activeColor = "#504945" { activeColor = "#504945"
, inactiveColor = "#282828" , inactiveColor = "#282828"
, activeBorderColor = "#504945" , activeBorderColor = "#fbf1c7"
, inactiveBorderColor = "#fbf1c7" , inactiveBorderColor = "#282828"
, activeTextColor = "#fbf1c7" , activeTextColor = "#fbf1c7"
, inactiveTextColor = "#fbf1c7" , inactiveTextColor = "#fbf1c7"
, fontName = "-*-jetbrains mono-medium-r-normal-12-0-0-0-0-m-0-ascii-1" , fontName = "-*-jetbrains mono-medium-r-normal-12-0-0-0-0-m-0-ascii-1"
} }
-- Transform layout modifier into a toggle-able
makeTabbed layout = windowNavigation $ addTabs shrinkText myTabTheme $ subLayout [] Simplest $ layout
-- layoutHints . -- layoutHints .
myLayout = avoidStruts . BoringWindows.boringWindows . smartBorders . toggleLayouts Full . layoutHintsToCenter $ layouts
myLayout = avoidStruts . smartBorders . ToggleLayouts.toggleLayouts resizableTabbedLayout . ToggleLayouts.toggleLayouts Full . layoutHintsToCenter $ layouts
where where
layouts =((rename "Tall" $ onlySpacing $ mouseResizableTile {draggerType = dragger}) -- ResizableTall 1 (3/100) (1/2) [] layouts =((rename "Tall" $ onlySpacing $ mouseResizableTile {draggerType = dragger})
||| (rename "Horizon" $ onlySpacing $ mouseResizableTileMirrored {draggerType = dragger}) -- Mirror $ ResizableTall 1 (3/100) (3/4) [] ||| (rename "Horizon" $ onlySpacing $ mouseResizableTileMirrored {draggerType = dragger})
||| (rename "BSP" $ spacingAndGaps $ borderResize $ emptyBSP) ||| (rename "BSP" $ spacingAndGaps $ borderResize $ emptyBSP)
||| (rename "ResTall" $ makeTabbed $ spacingAndGaps $ ResizableTall 1 (3/100) (1/2) []) ||| (rename "TabbedRow" $ makeTabbed $ spacingAndGaps $ zoomRow)
||| (rename "Row" $ makeTabbed $ spacingAndGaps $ zoomRow) ||| (rename "TabbedGrid" $ makeTabbed $ spacingAndGaps $ Grid False))
||| (rename "grid" $ makeTabbed $ spacingAndGaps $ Grid False))
-- ||| (rename "threeCol" $ spacingAndGaps $ ThreeColMid 1 (3/100) (1/2)) -- ||| (rename "threeCol" $ spacingAndGaps $ ThreeColMid 1 (3/100) (1/2))
-- ||| (rename "spiral" $ spacingAndGaps $ spiral (9/21)) -- ||| (rename "spiral" $ spacingAndGaps $ spiral (9/21))
rename n = renamed [Replace n] rename n = renamed [Replace n]
resizableTabbedLayout = rename "Tabbed" . BoringWindows.boringWindows . makeTabbed . spacingAndGaps $ ResizableTall 1 (3/100) (1/2) []
gap = 7 gap = 7
onlySpacing = gaps [ (dir, (gap*2)) | dir <- [L, R, D, U] ] -- gaps are included in mouseResizableTile onlySpacing = gaps [ (dir, (gap*2)) | dir <- [L, R, D, U] ] -- gaps are included in mouseResizableTile
dragger = let x = fromIntegral gap * 2 dragger = let x = fromIntegral gap * 2
@ -160,6 +156,10 @@ myLayout = avoidStruts . BoringWindows.boringWindows . smartBorders . toggleLayo
spacingAndGaps = let intGap = fromIntegral gap spacingAndGaps = let intGap = fromIntegral gap
border = Border (intGap) (intGap) (intGap) (intGap) border = Border (intGap) (intGap) (intGap) (intGap)
in spacingRaw False border True border True in spacingRaw False border True border True
-- transform a layout into supporting tabs
makeTabbed layout = windowNavigation $ addTabs shrinkText myTabTheme $ subLayout [] Simplest $ layout
-- }}} -- }}}
-- Startuphook ----------------------------- {{{ -- Startuphook ----------------------------- {{{
@ -204,8 +204,8 @@ myKeys =
-- Tabs -- Tabs
, ("M-j", BoringWindows.focusDown) , ("M-j", ifLayoutName ("Tabbed" `isPrefixOf`) (BoringWindows.focusDown) (windows W.focusDown))
, ("M-k", BoringWindows.focusUp) , ("M-k", ifLayoutName ("Tabbed" `isPrefixOf`) (BoringWindows.focusUp) (windows W.focusUp))
, ("M-C-S-h", sendMessage $ pullGroup L) , ("M-C-S-h", sendMessage $ pullGroup L)
, ("M-C-S-j", sendMessage $ pullGroup D) , ("M-C-S-j", sendMessage $ pullGroup D)
, ("M-C-S-k", sendMessage $ pullGroup U) , ("M-C-S-k", sendMessage $ pullGroup U)
@ -214,17 +214,17 @@ myKeys =
, ("M-S-C-<Backspace>", withFocused (sendMessage . UnMerge)) , ("M-S-C-<Backspace>", withFocused (sendMessage . UnMerge))
, ("M-<Tab>", onGroup W.focusDown') , ("M-<Tab>", onGroup W.focusDown')
, ("M-C-<Tab>", onGroup W.focusUp') , ("M-C-<Tab>", onGroup W.focusUp')
, ("M-t", toggleTabbedLayout)
, ("M-f", toggleFullscreen)
, ("M-f", toggleFullscreen) , ("M-S-C-c", kill1)
, ("M-S-C-q", io exitSuccess)
, ("M-S-C-c", kill1)
, ("M-S-C-q", io exitSuccess)
-- Binary space partitioning -- Binary space partitioning
, ("M-<Backspace>", sendMessage Swap) , ("M-<Backspace>", sendMessage Swap)
, ("M-M1-<Backspace>", sendMessage Rotate) , ("M-M1-<Backspace>", sendMessage Rotate)
-- Media -- Media
@ -279,11 +279,22 @@ myKeys =
] ]
toggleTabbedLayout :: X ()
toggleTabbedLayout = do
sendMessage $ ToggleLayouts.Toggle "Tabbed"
ifLayoutIs "Tabbed" (do BoringWindows.focusMaster
withFocused (sendMessage . MergeAll)
withFocused (sendMessage . UnMerge)
-- refresh the tabs, so they draw correctly
windows W.focusUp
windows W.focusDown)
(return ())
toggleFullscreen :: X () toggleFullscreen :: X ()
toggleFullscreen = do toggleFullscreen = do
sendMessage ToggleLayout -- toggle fullscreen layout --sendMessage ToggleLayout -- toggle fullscreen layout
sendMessage $ ToggleLayouts.Toggle "Full"
sendMessage ToggleStruts -- bar is hidden -> no need to make place for it sendMessage ToggleStruts -- bar is hidden -> no need to make place for it
--safeSpawn "polybar-msg" ["cmd", "toggle"] -- toggle polybar visibility --safeSpawn "polybar-msg" ["cmd", "toggle"] -- toggle polybar visibility
@ -446,9 +457,12 @@ promptDzenWhileRunning promptTitle options action = do
font = "-*-iosevka-medium-r-s*--16-87-*-*-*-*-iso10???-1" font = "-*-iosevka-medium-r-s*--16-87-*-*-*-*-iso10???-1"
ifLayoutIs :: String -> X a -> X a -> X a ifLayoutIs :: String -> X a -> X a -> X a
ifLayoutIs layoutAName onLayoutA onLayoutB = do ifLayoutIs layoutAName = ifLayoutName (== layoutAName)
ifLayoutName :: (String -> Bool) -> X a -> X a -> X a
ifLayoutName check onLayoutA onLayoutB = do
layout <- getActiveLayoutDescription layout <- getActiveLayoutDescription
if (layout == layoutAName) then onLayoutA else onLayoutB if (check layout) then onLayoutA else onLayoutB
-- Get the name of the active layout. -- Get the name of the active layout.
getActiveLayoutDescription :: X String getActiveLayoutDescription :: X String