aboutsummaryrefslogtreecommitdiff
path: root/src/Rahm/Desktop/Swallow.hs
diff options
context:
space:
mode:
authorJosh Rahm <joshuarahm@gmail.com>2022-04-10 13:26:16 -0600
committerJosh Rahm <joshuarahm@gmail.com>2022-10-09 12:19:46 -0600
commita652c330707e2e9bbe963e01af79ce730cf3452e (patch)
tree047655195f50efcbd51db8f825acf589dc6abead /src/Rahm/Desktop/Swallow.hs
parent381a3e5a00813314249bb74b5460f5ff5a4006bb (diff)
downloadrde-a652c330707e2e9bbe963e01af79ce730cf3452e.tar.gz
rde-a652c330707e2e9bbe963e01af79ce730cf3452e.tar.bz2
rde-a652c330707e2e9bbe963e01af79ce730cf3452e.zip
Rename Internal to Rahm.Desktop
Diffstat (limited to 'src/Rahm/Desktop/Swallow.hs')
-rw-r--r--src/Rahm/Desktop/Swallow.hs29
1 files changed, 29 insertions, 0 deletions
diff --git a/src/Rahm/Desktop/Swallow.hs b/src/Rahm/Desktop/Swallow.hs
new file mode 100644
index 0000000..1939c58
--- /dev/null
+++ b/src/Rahm/Desktop/Swallow.hs
@@ -0,0 +1,29 @@
+module Rahm.Desktop.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