[XMonad] Add automatic workspace naming LayoutModifier
Note: This requires my own custom version of xmonad-contrib.
This commit is contained in:
parent
f25f543b17
commit
cd9a67706a
@ -1,3 +1,4 @@
|
||||
{-# LANGUAGE TypeSynonymInstances, MultiParamTypeClasses #-}
|
||||
import Control.Monad
|
||||
import Data.Aeson
|
||||
import qualified Data.ByteString.Lazy as B
|
||||
@ -20,6 +21,7 @@ import XMonad.Hooks.ManageDocks
|
||||
import XMonad.Hooks.FadeInactive
|
||||
import XMonad.Layout.BoringWindows
|
||||
import XMonad.Layout.LayoutCombinators
|
||||
import XMonad.Layout.LayoutModifier
|
||||
import XMonad.Layout.Minimize
|
||||
import XMonad.Layout.MultiColumns
|
||||
import XMonad.Layout.MultiToggle
|
||||
@ -28,6 +30,7 @@ import XMonad.Layout.NoBorders
|
||||
import XMonad.Layout.Spacing
|
||||
import qualified XMonad.StackSet as W
|
||||
import XMonad.Util.CustomKeys
|
||||
import qualified XMonad.Util.ExtensibleState as XS
|
||||
import XMonad.Util.NamedWindows (getName)
|
||||
|
||||
getClass :: Window -> X String
|
||||
@ -65,13 +68,13 @@ main = xmonad $ ewmh $ pagerHints def
|
||||
|
||||
myLogHook = fadeInactiveLogHook 0.9
|
||||
|
||||
setWorkspaceNameToFocusedWindow workspace = do
|
||||
namedWindows <- mapM getClass $ take 2 $ W.integrate' $ W.stack workspace
|
||||
workspaceToName <- getWorkspaceNames
|
||||
setWorkspaceNameToFocusedWindow workspace = do
|
||||
namedWindows <- mapM getClass $ W.integrate' $ W.stack workspace
|
||||
renamedWindows <- remapNames namedWindows
|
||||
let newName = intercalate "|" namedWindows
|
||||
when (workspaceToName (W.tag workspace) /= newName) $
|
||||
setWorkspaceName (W.tag workspace) (intercalate "|" renamedWindows)
|
||||
WorkspaceNames namesMap <- XS.get
|
||||
let newName = intercalate "|" renamedWindows
|
||||
currentName = M.findWithDefault "" (W.tag workspace) namesMap
|
||||
when (currentName /= newName) $ setWorkspaceName (W.tag workspace) newName
|
||||
|
||||
remapNames namedWindows = do
|
||||
remap <- io getClassRemap
|
||||
@ -81,12 +84,20 @@ setWorkspaceNames = do
|
||||
ws <- gets windowset
|
||||
mapM_ setWorkspaceNameToFocusedWindow (W.workspaces ws)
|
||||
|
||||
data WorkspaceNamesHook a = WorkspaceNamesHook deriving (Show, Read)
|
||||
|
||||
instance LayoutModifier WorkspaceNamesHook Window where
|
||||
hook _ = setWorkspaceNames
|
||||
|
||||
workspaceNamesHook = ModifiedLayout WorkspaceNamesHook
|
||||
|
||||
shiftThenView i = W.greedyView i . W.shift i
|
||||
|
||||
layouts = multiCol [1, 1] 2 0.01 (-0.5) ||| Full ||| Tall 1 (3/100) (1/2)
|
||||
|
||||
myLayoutHook = avoidStruts . smartSpacing 10 . noBorders . minimize
|
||||
. boringWindows . mkToggle (MIRROR ?? EOT) $ layouts
|
||||
myLayoutHook = avoidStruts . smartSpacing 10 . noBorders . minimize .
|
||||
boringWindows . mkToggle (MIRROR ?? EOT) . workspaceNamesHook
|
||||
$ layouts
|
||||
|
||||
myStartup = spawn "systemctl --user start wm.target"
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user