Skip to content

Instantly share code, notes, and snippets.

@LSLeary
Last active August 5, 2022 12:53
Show Gist options
  • Save LSLeary/399475bd7c5b063a5ff623730db64adb to your computer and use it in GitHub Desktop.
Save LSLeary/399475bd7c5b063a5ff623730db64adb to your computer and use it in GitHub Desktop.
Modify an action to integrate it with RefocusLast.
module ThenRefocusAfter where
import XMonad
import XMonad.Hooks.RefocusLast (refocusWhen)
import XMonad.Util.NamedScratchpad
(NamedScratchpads, query, namedScratchpadAction)
import qualified XMonad.StackSet as W
thenRefocusAfter :: Query Bool -> X a -> X a
p `thenRefocusAfter` act = do
tag <- gets (W.currentTag . windowset)
refocus <- refocusWhen p tag
act <* windows refocus
isScratchpad :: NamedScratchpads -> Query Bool
isScratchpad = foldr (\ns b -> query ns <||> b) (pure False)
namedScratchpadActionRL :: NamedScratchpads -> String -> X ()
namedScratchpadActionRL nsps sp =
isScratchpad nsps `thenRefocusAfter` namedScratchpadAction nsps sp
@txtyash
Copy link

txtyash commented Aug 5, 2022

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment