xmonad: remove tabbed windows and refactor

This commit is contained in:
Ingolf Wagner 2019-11-27 10:19:19 +13:00
parent 783723c1e4
commit 51ad3fc549
No known key found for this signature in database
GPG key ID: 76BF5F1928B9618B

View file

@ -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,31 +81,37 @@ 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"
[ Project
{ projectName = "chat"
, projectDirectory = "~/"
, projectStartHook = Just $ do spawn nixStartIrc
, projectStartHook = Just $ spawn nixStartIrc
}
, Project { projectName = "audio"
, Project
{ projectName = "audio"
, projectDirectory = "~/music-library"
, projectStartHook = Just $ do spawn nixStartAudacious
, projectStartHook = Just $ spawn nixStartAudacious
}
, Project { projectName = "nixos"
, Project
{ projectName = "nixos"
, projectDirectory = "~/dev/krops"
, projectStartHook = Nothing
}
, Project { projectName = "-copyq"
, Project
{ projectName = "-copyq"
, projectDirectory = "~/"
, projectStartHook = Just $ do spawn nixShowCopyq
, projectStartHook = Just $ spawn nixShowCopyq
}
]
@ -219,9 +195,9 @@ myAdditionaKeys
=
(multiKeys
[ ( "`"
, do
removeEmptyWorkspaceAfterExcept nonRemovableWorkspaces
( withWorkspace autoXPConfig (windows . W.greedyView ))
, do removeEmptyWorkspaceAfterExcept
nonRemovableWorkspaces
(withWorkspace autoXPConfig (windows . W.greedyView))
updateBoring)
-- move focused window to workspace
, ("S-<Space>", withWorkspace myXPConfig (windows . W.shift))
@ -231,18 +207,19 @@ myAdditionaKeys
, ( "s"
, do copies <- wsContainingCopies
if not (null copies)
then do killAllOtherCopies
then do
killAllOtherCopies
clearBoring
else do windows copyToAll
withFocused (\w -> broadcastMessage (IsBoring w) )
)
else do
windows copyToAll
withFocused (broadcastMessage . IsBoring))
-- rename workspace but make sure myWorkspaces still exist
, ( "r"
, do renameWorkspace myXPConfig
sequence_ [addHiddenWorkspace ws | ws <- myWorkspaces])
, ("<Esc>", do toggleWS' ["NSP"]
updateBoring
)
, ( "<Esc>"
, do toggleWS' ["NSP"]
updateBoring)
]) ++
-- ------------------------------------------------------------
--
@ -254,7 +231,8 @@ myAdditionaKeys
[ ("<Return>", spawn $ XMonad.terminal defaults)
, ("q", kill1)
-- open scratchpad
, ("-", do scratchpadSpawnAction defaults
, ( "-"
, do scratchpadSpawnAction defaults
updateBoring)
]) ++
[ ( "<Print>"
@ -269,37 +247,23 @@ myAdditionaKeys
--
-- ------------------------------------------------------------
(multiKeys
[
-- remove window from tabbed group
("i", withFocused (sendMessage . UnMerge))
-- merge with left window
, ("<Left>", sendMessage $ pullGroup L)
, ("S-<Left>", sendMessage $ pullGroup L)
-- merge with right window
, ("<Right>", sendMessage $ pullGroup R)
, ("S-<Right>", sendMessage $ pullGroup R)
-- merge with upper window
, ("<Up>", sendMessage $ pullGroup U)
, ("S-<Up>", sendMessage $ pullGroup U)
-- merge with lower window
, ("<Down>", sendMessage $ pullGroup D)
, ("S-<Down>", sendMessage $ pullGroup D)
-- Change the selection in the tabbed Subgroup
, ("o", onGroup W.focusDown')
-- Move focus to the next window
, ("j", do sendMessage FirstLayout
[ ( "j"
, do sendMessage FirstLayout
focusDown)
-- Move focus to the previous window
, ("k", do sendMessage FirstLayout
, ( "k"
, do sendMessage FirstLayout
focusUp)
-- Swap the focused window and the master window
, ("<Tab>", windows W.swapMaster)
-- Swap the focused window with the next window
, ("S-j", do sendMessage FirstLayout
, ( "S-j"
, do sendMessage FirstLayout
windows W.swapDown)
-- Swap the focused window with the previous window
, ("S-k", do sendMessage FirstLayout
, ( "S-k"
, do sendMessage FirstLayout
windows W.swapUp)
-- Rotate through the available layout algorithms
, ("f", sendMessage NextLayout)
@ -367,10 +331,7 @@ myAdditionaKeys
-- Redshift
--
-- ------------------------------------------------------------
[ ("M4-<F9>", spawn nixStartRedshift)
, ("M4-<F10>", spawn nixResetRedshift)
]
[("M4-<F9>", spawn nixStartRedshift), ("M4-<F10>", 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