Created
January 1, 2024 17:21
-
-
Save portnov/4db3caf2cc606d96accef78a514281ff to your computer and use it in GitHub Desktop.
Default layouts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module DefaultLayouts where | |
import Control.Monad | |
import qualified Data.Set as S | |
import qualified Data.Map as M | |
import XMonad | |
import qualified XMonad.Util.ExtensibleState as XS | |
import XMonad.Utils | |
type LayoutPerWorkspace = M.Map WorkspaceId String | |
newtype SeenWorkspaces = SeenWorkspaces (S.Set WorkspaceId) | |
deriving (Eq, Read, Show, Typeable) | |
instance ExtensionClass SeenWorkspaces where | |
initialValue = SeenWorkspaces S.empty | |
extensionType = PersistentExtension | |
dfltLayoutPerWorkspace :: LayoutPerWorkspace -> X () | |
dfltLayoutPerWorkspace m = do | |
wksp <- getCurrentWorkspace | |
SeenWorkspaces seen <- XS.get | |
unless (wksp `S.member` seen) $ do | |
whenJust (M.lookup wksp m) $ \layoutName -> do | |
sendMessage (JumpToLayout layoutName) | |
XS.put $ SeenWorkspaces $ S.insert wksp seen | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import DefaultLayouts | |
myLayouts = named "tall" (Tall 1 (1/100) (1/2)) ||| named "grid" Grid ||| ... | |
dfltLayouts = M.fromList [("1", "tall"), ("2", "grid"), ...] | |
main = xmonad $ def { | |
workspaces = ["1", "2", "3" ...], | |
layoutHook = myLayouts, | |
logHook = dfltLayoutPerWorkspace dfltLayouts | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment