aboutsummaryrefslogtreecommitdiff
path: root/src/Internal/Swallow.hs
blob: 3e4112fb1a3445931e5cf3438e53f547698e2b18 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
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