aboutsummaryrefslogtreecommitdiff
path: root/src/Config.hs
blob: e76e6ea532e49c5c6c00b81394e6151cfe8a9fa9 (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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
module Config (config) where

import Control.Monad (unless)
import Data.Bits
import Data.Data (Proxy (Proxy))
import Wetterhorn.Core.ButtonEvent as ButtonEvent
import Wetterhorn.Core.KeyEvent as KeyEvent
import Wetterhorn.Core.W
import Wetterhorn.Dsl.Bind
import Wetterhorn.Dsl.Input
import Wetterhorn.Keys.Macros
import Wetterhorn.Keys.MagicModifierKey
import Wetterhorn.Layout.Full

config :: Config WindowLayout
config =
  defaultConfig
    { hooks =
        defaultHooks
          { surfaceHook = do
              handleSurface
          },
      layout = WindowLayout Full,
      resetHook = do
        useInputHandler $
          withProxies inputProxies $ do
            ev <- nextInputEvent

            bind ev (released btnLeft) $
              run $
                wio $
                  putStrLn "Left Button Released!!"

            unless (isPressEvent ev) $ do
              forwardEvent ev
              continue

            bind ev (Shift .+ Mod1 .+ 'R') $ run requestHotReload

            bind ev (Mod1 .+ 't') $ run (shellExec "alacritty")

            bind ev (Mod1 .+ 'p') $ do
              ev2 <- nextInputPressEvent

              bind ev2 (Mod1 .+ 'p') $
                run $
                  wio $
                    putStrLn "Test"

            bind ev (Mod1 .+ btnLeft) $
              run $
                wio $
                  putStrLn "Left Button Press!!"

            bind ev (Mod1 .+ 'q') macroStartStopKeybind

            bind ev (weak $ Mod1 .+ '@') macroReplayKeybind

            bind ev (weak $ ModX 5 .+ btnLeft) $
              run $
                wio $
                  putStrLn "Fake Modifier With Button!!!"

            bind ev (weak $ ModX 5 .+ 't') $
              run $
                wio $
                  putStrLn "Fake Modifier!!"

            forwardEvent ev
    }
  where
    inputProxies ::
      Proxy
        '[ MacroSupport,
           MagicModifierProxy 59 SetXtra -- Only log keys when F1 (keycode 59 is pressed)
         ]
    inputProxies = Proxy

data SetXtra

instance InputProxy SetXtra where
  onKeyEvent _ ie =
    case ie of
      (InputKeyEvent ke@(KeyEvent {KeyEvent.modifiers = modifiers})) ->
        return $ InputKeyEvent ke {KeyEvent.modifiers = modifiers .|. modifierToMask (ModX 5)}
      (InputButtonEvent be@(ButtonEvent {ButtonEvent.modifiers = modifiers})) ->
        return $ InputButtonEvent be {ButtonEvent.modifiers = modifiers .|. modifierToMask (ModX 5)}
      _ -> return ie