From ea291e76b2ab45e13f648e82b63c4668974c2eae Mon Sep 17 00:00:00 2001 From: Josh Rahm Date: Mon, 4 Dec 2023 14:32:11 -0700 Subject: Add ability to swap two workspaces with the W command --- src/Rahm/Desktop/SwapMaster.hs | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) (limited to 'src/Rahm/Desktop/SwapMaster.hs') diff --git a/src/Rahm/Desktop/SwapMaster.hs b/src/Rahm/Desktop/SwapMaster.hs index 68072a9..f95303d 100644 --- a/src/Rahm/Desktop/SwapMaster.hs +++ b/src/Rahm/Desktop/SwapMaster.hs @@ -26,16 +26,13 @@ import XMonad import qualified XMonad.Util.ExtensibleState as XS (get, modify, put) newtype LastWindow = LastWindow - { lastWindow :: Map String Window + { lastWindows :: Map String Window } deriving (Show, Read) instance ExtensionClass LastWindow where initialValue = LastWindow mempty -hoist :: (Monad m) => Maybe a -> MaybeT m a -hoist = MaybeT . return - swapMaster :: X () swapMaster = runMaybeT_ $ do @@ -49,7 +46,7 @@ swapMaster = return (a, b) lift $ do - st <- lastWindow <$> XS.get + st <- lastWindows <$> XS.get windows . W.swapWindows $ case focused == master of True @@ -58,7 +55,8 @@ swapMaster = False -> [(master, focused)] _ -> [] - XS.modify $ - \(LastWindow m) -> - LastWindow $ Map.insert (W.currentTag ss) master m + XS.modify $ mlw (Map.insert (W.currentTag ss) master) windows W.focusMaster + where + mlw fn (LastWindow l) = LastWindow (fn l) + hoist = MaybeT . return -- cgit