From f9515a7669976b8f2fe80e9b93ba1b97528954d2 Mon Sep 17 00:00:00 2001 From: Josh Rahm Date: Mon, 28 Mar 2022 22:59:16 -0600 Subject: Forgot to add the Swallow.hs file --- src/Internal/Swallow.hs | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 src/Internal/Swallow.hs diff --git a/src/Internal/Swallow.hs b/src/Internal/Swallow.hs new file mode 100644 index 0000000..3e4112f --- /dev/null +++ b/src/Internal/Swallow.hs @@ -0,0 +1,29 @@ +module Internal.Swallow ( + swallowHook, setSwallowEnabled, isSwallowEnabled, toggleSwallowEnabled) where + +import XMonad +import Data.Monoid (All) +import XMonad.Hooks.WindowSwallowing +import XMonad.Util.ExtensibleState as XS + +data DisableSwallow = DisableSwallow Bool deriving (Show) + +swallowHook :: Event -> X All +swallowHook = swallowEventHook (className =? "Alacritty") $ + liftX $ do + (DisableSwallow disable) <- XS.get + return (not disable) + +isSwallowEnabled :: X Bool +isSwallowEnabled = do + (DisableSwallow b) <- XS.get + return (not b) + +setSwallowEnabled :: Bool -> X () +setSwallowEnabled enable = XS.modify $ const $ DisableSwallow $ not enable + +toggleSwallowEnabled :: X () +toggleSwallowEnabled = (setSwallowEnabled . not) =<< isSwallowEnabled + +instance ExtensionClass DisableSwallow where + initialValue = DisableSwallow False -- cgit