forked from colonelpanic/dotfiles
[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 Control.Monad
|
||||||
import Data.Aeson
|
import Data.Aeson
|
||||||
import qualified Data.ByteString.Lazy as B
|
import qualified Data.ByteString.Lazy as B
|
||||||
@ -20,6 +21,7 @@ import XMonad.Hooks.ManageDocks
|
|||||||
import XMonad.Hooks.FadeInactive
|
import XMonad.Hooks.FadeInactive
|
||||||
import XMonad.Layout.BoringWindows
|
import XMonad.Layout.BoringWindows
|
||||||
import XMonad.Layout.LayoutCombinators
|
import XMonad.Layout.LayoutCombinators
|
||||||
|
import XMonad.Layout.LayoutModifier
|
||||||
import XMonad.Layout.Minimize
|
import XMonad.Layout.Minimize
|
||||||
import XMonad.Layout.MultiColumns
|
import XMonad.Layout.MultiColumns
|
||||||
import XMonad.Layout.MultiToggle
|
import XMonad.Layout.MultiToggle
|
||||||
@ -28,6 +30,7 @@ import XMonad.Layout.NoBorders
|
|||||||
import XMonad.Layout.Spacing
|
import XMonad.Layout.Spacing
|
||||||
import qualified XMonad.StackSet as W
|
import qualified XMonad.StackSet as W
|
||||||
import XMonad.Util.CustomKeys
|
import XMonad.Util.CustomKeys
|
||||||
|
import qualified XMonad.Util.ExtensibleState as XS
|
||||||
import XMonad.Util.NamedWindows (getName)
|
import XMonad.Util.NamedWindows (getName)
|
||||||
|
|
||||||
getClass :: Window -> X String
|
getClass :: Window -> X String
|
||||||
@ -65,13 +68,13 @@ main = xmonad $ ewmh $ pagerHints def
|
|||||||
|
|
||||||
myLogHook = fadeInactiveLogHook 0.9
|
myLogHook = fadeInactiveLogHook 0.9
|
||||||
|
|
||||||
setWorkspaceNameToFocusedWindow workspace = do
|
setWorkspaceNameToFocusedWindow workspace = do
|
||||||
namedWindows <- mapM getClass $ take 2 $ W.integrate' $ W.stack workspace
|
namedWindows <- mapM getClass $ W.integrate' $ W.stack workspace
|
||||||
workspaceToName <- getWorkspaceNames
|
|
||||||
renamedWindows <- remapNames namedWindows
|
renamedWindows <- remapNames namedWindows
|
||||||
let newName = intercalate "|" namedWindows
|
WorkspaceNames namesMap <- XS.get
|
||||||
when (workspaceToName (W.tag workspace) /= newName) $
|
let newName = intercalate "|" renamedWindows
|
||||||
setWorkspaceName (W.tag workspace) (intercalate "|" renamedWindows)
|
currentName = M.findWithDefault "" (W.tag workspace) namesMap
|
||||||
|
when (currentName /= newName) $ setWorkspaceName (W.tag workspace) newName
|
||||||
|
|
||||||
remapNames namedWindows = do
|
remapNames namedWindows = do
|
||||||
remap <- io getClassRemap
|
remap <- io getClassRemap
|
||||||
@ -81,12 +84,20 @@ setWorkspaceNames = do
|
|||||||
ws <- gets windowset
|
ws <- gets windowset
|
||||||
mapM_ setWorkspaceNameToFocusedWindow (W.workspaces ws)
|
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
|
shiftThenView i = W.greedyView i . W.shift i
|
||||||
|
|
||||||
layouts = multiCol [1, 1] 2 0.01 (-0.5) ||| Full ||| Tall 1 (3/100) (1/2)
|
layouts = multiCol [1, 1] 2 0.01 (-0.5) ||| Full ||| Tall 1 (3/100) (1/2)
|
||||||
|
|
||||||
myLayoutHook = avoidStruts . smartSpacing 10 . noBorders . minimize
|
myLayoutHook = avoidStruts . smartSpacing 10 . noBorders . minimize .
|
||||||
. boringWindows . mkToggle (MIRROR ?? EOT) $ layouts
|
boringWindows . mkToggle (MIRROR ?? EOT) . workspaceNamesHook
|
||||||
|
$ layouts
|
||||||
|
|
||||||
myStartup = spawn "systemctl --user start wm.target"
|
myStartup = spawn "systemctl --user start wm.target"
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user