Created
September 11, 2025 16:38
-
-
Save LSLeary/28e2157ccb7eb83cf6b63d9a5aed4dd0 to your computer and use it in GitHub Desktop.
xmonad: switch to the previous layout (experimental)
This file contains hidden or 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 PrevLayout (prevLayout) where | |
import XMonad | |
import qualified XMonad.StackSet as W | |
prevLayout :: X () | |
prevLayout = do | |
[email protected]{ W.current = [email protected]{ W.workspace = ws }} <- gets windowset | |
mp <- findPrev (description (W.layout ws)) (W.layout ws) | |
case mp of | |
Nothing -> pure () | |
Just p -> windows | |
$ const ss{ W.current = c{ W.workspace = ws{ W.layout = p } } } | |
where | |
findPrev cur l = do | |
ml' <- handleMessage l (SomeMessage NextLayout) | |
case ml' of | |
Nothing -> pure Nothing | |
Just l' -> if description l' == cur | |
then pure (Just l) | |
else findPrev cur l' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
BTW,
findPrev (description (W.layout ws)) (W.layout ws)
is the same asdescription >>= findPrev $ W.layout
, in the name of the function monad 🤣