From 51ad3fc54913f160381f5681e4cf6bc0393a9ee7 Mon Sep 17 00:00:00 2001 From: Ingolf Wagner Date: Wed, 27 Nov 2019 10:19:19 +1300 Subject: [PATCH] xmonad: remove tabbed windows and refactor --- system/desktop/home-manager/xmonad/Main.hs | 159 ++++++++------------- 1 file changed, 61 insertions(+), 98 deletions(-) diff --git a/system/desktop/home-manager/xmonad/Main.hs b/system/desktop/home-manager/xmonad/Main.hs index a95bdf2..0396877 100644 --- a/system/desktop/home-manager/xmonad/Main.hs +++ b/system/desktop/home-manager/xmonad/Main.hs @@ -5,17 +5,13 @@ module Main where import BoringWindows (BoringMessage (..), boringWindows, clearBoring, - focusDown, focusUp, - markBoring) + focusDown, focusUp) import qualified Data.Map as M import Data.Monoid (All, Endo) import Data.Ratio ((%)) import FloatKeys (keysResizeWindow) import NixCommands import qualified SolarizedLight as Solarized -import SubLayouts (GroupMsg (..), onGroup, - pullGroup, subLayout, - subTabbed) import System.Exit import XMonad import XMonad.Actions.CopyWindow (copy, copyToAll, kill1, @@ -29,21 +25,17 @@ import XMonad.Actions.DynamicWorkspaces (addHiddenWorkspace, removeEmp withWorkspace) import XMonad.Actions.UpdatePointer (updatePointer) import XMonad.Actions.Warp (warpToScreen) -import XMonad.Hooks.DynamicLog (PP (..), dynamicLog, shorten, - statusBar, wrap) +import XMonad.Hooks.DynamicLog (dynamicLog) import XMonad.Hooks.ManageDebug (debugManageHook) import XMonad.Hooks.ManageHelpers (doCenterFloat) import XMonad.Hooks.SetWMName (setWMName) -import XMonad.Hooks.UrgencyHook (BorderUrgencyHook (..), - SpawnUrgencyHook (..), +import XMonad.Hooks.UrgencyHook (SpawnUrgencyHook (..), withUrgencyHook) -import XMonad.Layout.Mosaic (Aspect (Reset), mosaic) +import XMonad.Layout.Mosaic (Aspect (Reset)) import XMonad.Layout.NoBorders (noBorders, smartBorders) import XMonad.Layout.ResizableTile (MirrorResize (MirrorExpand, MirrorShrink), ResizableTall (..)) -import XMonad.Layout.Simplest (Simplest (..)) -import XMonad.Layout.Tabbed (TabbedDecoration, addTabs, - shrinkText) +import XMonad.Layout.StateFull (focusTracking) import XMonad.Layout.WindowNavigation (configurableNavigation, noNavigateBorders) import XMonad.Prompt (XPConfig (..)) @@ -52,13 +44,6 @@ import XMonad.Util.EZConfig (additionalKeysP) import XMonad.Util.Scratchpad (scratchpadManageHook, scratchpadSpawnAction) import XMonad.Util.SpawnOnce (spawnOnce) -import XMonad.Util.Types (Direction2D (D, L, R, U)) - -import TabbedFix (historyLayout, runAllPending) -import XMonad.Layout.StateFull (focusTracking) - --- only needed to retrigger a build -import XMonad.Layout.DwmStyle ------------------------------------------------------------------------ -- @@ -72,8 +57,7 @@ selectionColor = Solarized.violet nonSelectionColor :: String nonSelectionColor = Solarized.base02 --- http://hackage.haskell.org/package/xmonad-contrib-0.15/docs/XMonad-Layout-Tabbed.html#t:Theme -myLayout = (windowConfiguration $ myTabbed $ mySubLayout $ boringWindows resizeableTall) ||| noBorders Full +myLayout = (windowConfiguration $ smartBorders $ boringWindows resizeableTall) ||| noBorders Full where resizeableTall = ResizableTall nmaster delta ratio [] -- The default number of windows in the master pane @@ -85,20 +69,6 @@ myLayout = (windowConfiguration $ myTabbed $ mySubLayout $ boringWindows resize windowConfiguration = configurableNavigation noNavigateBorders - myTabbed x = smartBorders $ addTabs shrinkText windowDecoration x - - mySubLayout = subLayout [] Simplest - - windowDecoration = def { activeColor = selectionColor - , activeBorderColor = selectionColor - , activeTextColor = Solarized.base03 - , inactiveColor = nonSelectionColor - , inactiveBorderColor = nonSelectionColor - , inactiveTextColor = Solarized.base0 - , fontName = "-*-terminus-medium-*-*-*-10101010-*-*-*-*-*-*-*" - , decoHeight = 11 - } - -- ------------------------------------------------------------ -- @@ -111,32 +81,38 @@ myWorkspaces :: [String] myWorkspaces = ["1", "2", "3", "4"] -- workspaces names to be used only by one program, partly spawning on startup. +autoSpawnWorkspaces :: [ String ] autoSpawnWorkspaces = [ "-copyq" ] -- theses workspaces should not be removed by the workspace -- switch commands +nonRemovableWorkspaces :: [ String ] nonRemovableWorkspaces = myWorkspaces ++ autoSpawnWorkspaces -- projects -- named workspaces with predefined behavior projects :: [Project] projects = - [ Project { projectName = "chat" - , projectDirectory = "~/" - , projectStartHook = Just $ do spawn nixStartIrc - } - , Project { projectName = "audio" - , projectDirectory = "~/music-library" - , projectStartHook = Just $ do spawn nixStartAudacious - } - , Project { projectName = "nixos" - , projectDirectory = "~/dev/krops" - , projectStartHook = Nothing - } - , Project { projectName = "-copyq" - , projectDirectory = "~/" - , projectStartHook = Just $ do spawn nixShowCopyq - } + [ Project + { projectName = "chat" + , projectDirectory = "~/" + , projectStartHook = Just $ spawn nixStartIrc + } + , Project + { projectName = "audio" + , projectDirectory = "~/music-library" + , projectStartHook = Just $ spawn nixStartAudacious + } + , Project + { projectName = "nixos" + , projectDirectory = "~/dev/krops" + , projectStartHook = Nothing + } + , Project + { projectName = "-copyq" + , projectDirectory = "~/" + , projectStartHook = Just $ spawn nixShowCopyq + } ] -- ------------------------------------------------------------ @@ -219,10 +195,10 @@ myAdditionaKeys = (multiKeys [ ( "`" - , do - removeEmptyWorkspaceAfterExcept nonRemovableWorkspaces - ( withWorkspace autoXPConfig (windows . W.greedyView )) - updateBoring) + , do removeEmptyWorkspaceAfterExcept + nonRemovableWorkspaces + (withWorkspace autoXPConfig (windows . W.greedyView)) + updateBoring) -- move focused window to workspace , ("S-", withWorkspace myXPConfig (windows . W.shift)) -- copy focused window to workspace @@ -231,18 +207,19 @@ myAdditionaKeys , ( "s" , do copies <- wsContainingCopies if not (null copies) - then do killAllOtherCopies - clearBoring - else do windows copyToAll - withFocused (\w -> broadcastMessage (IsBoring w) ) - ) + then do + killAllOtherCopies + clearBoring + else do + windows copyToAll + withFocused (broadcastMessage . IsBoring)) -- rename workspace but make sure myWorkspaces still exist , ( "r" , do renameWorkspace myXPConfig sequence_ [addHiddenWorkspace ws | ws <- myWorkspaces]) - , ("", do toggleWS' ["NSP"] - updateBoring - ) + , ( "" + , do toggleWS' ["NSP"] + updateBoring) ]) ++ -- ------------------------------------------------------------ -- @@ -254,8 +231,9 @@ myAdditionaKeys [ ("", spawn $ XMonad.terminal defaults) , ("q", kill1) -- open scratchpad - , ("-", do scratchpadSpawnAction defaults - updateBoring) + , ( "-" + , do scratchpadSpawnAction defaults + updateBoring) ]) ++ [ ( "" -- create screenshot @@ -269,38 +247,24 @@ myAdditionaKeys -- -- ------------------------------------------------------------ (multiKeys - [ - -- remove window from tabbed group - ("i", withFocused (sendMessage . UnMerge)) - -- merge with left window - , ("", sendMessage $ pullGroup L) - , ("S-", sendMessage $ pullGroup L) - -- merge with right window - , ("", sendMessage $ pullGroup R) - , ("S-", sendMessage $ pullGroup R) - -- merge with upper window - , ("", sendMessage $ pullGroup U) - , ("S-", sendMessage $ pullGroup U) - -- merge with lower window - , ("", sendMessage $ pullGroup D) - , ("S-", sendMessage $ pullGroup D) - -- Change the selection in the tabbed Subgroup - , ("o", onGroup W.focusDown') - -- Move focus to the next window - , ("j", do sendMessage FirstLayout - focusDown) + [ ( "j" + , do sendMessage FirstLayout + focusDown) -- Move focus to the previous window - , ("k", do sendMessage FirstLayout - focusUp) + , ( "k" + , do sendMessage FirstLayout + focusUp) -- Swap the focused window and the master window , ("", windows W.swapMaster) -- Swap the focused window with the next window - , ("S-j", do sendMessage FirstLayout - windows W.swapDown) + , ( "S-j" + , do sendMessage FirstLayout + windows W.swapDown) -- Swap the focused window with the previous window - , ("S-k", do sendMessage FirstLayout - windows W.swapUp) + , ( "S-k" + , do sendMessage FirstLayout + windows W.swapUp) -- Rotate through the available layout algorithms , ("f", sendMessage NextLayout) -- Shrink the current area @@ -367,10 +331,7 @@ myAdditionaKeys -- Redshift -- -- ------------------------------------------------------------ - [ ("M4-", spawn nixStartRedshift) - , ("M4-", spawn nixResetRedshift) - - ] + [("M4-", spawn nixStartRedshift), ("M4-", spawn nixResetRedshift)] ------------------------------------------------------------------------ -- Mouse bindings: default actions bound to mouse events @@ -524,8 +485,10 @@ defaults = , keys = myKeys , mouseBindings = mouse - , layoutHook = focusTracking $ historyLayout myLayout - , logHook = myLogHook <> runAllPending + -- , layoutHook = focusTracking $ historyLayout myLayout + , layoutHook = focusTracking myLayout + -- , logHook = myLogHook <> runAllPending + , logHook = myLogHook , startupHook = startUp , manageHook = myManageHook