aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJosh Rahm <rahm@google.com>2022-03-28 22:59:16 -0600
committerJosh Rahm <joshuarahm@gmail.com>2022-10-09 12:19:45 -0600
commit860b066cc2d2af8f193fdb52775543210d81fa7d (patch)
treebd3f7133334f2ce601ef994c37bfe6883143ae45 /src
parent8a87b96dceb52cd3090bd9c2b1c5648f310389b0 (diff)
downloadrde-860b066cc2d2af8f193fdb52775543210d81fa7d.tar.gz
rde-860b066cc2d2af8f193fdb52775543210d81fa7d.tar.bz2
rde-860b066cc2d2af8f193fdb52775543210d81fa7d.zip
Forgot to add the Swallow.hs file
Diffstat (limited to 'src')
-rw-r--r--src/Internal/Swallow.hs29
1 files changed, 29 insertions, 0 deletions
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