aboutsummaryrefslogtreecommitdiff
path: root/src/Config.hs
blob: 5f09cbe7c4bc167b73a95ce690916aa02bfcd3e7 (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
module Config (config) where

import Text.Printf
import Control.Monad.IO.Class
import Control.Monad.Loops
import Wetterhorn.Core.KeyEvent qualified as KeyEvent
import Wetterhorn.Core.Keys
import Wetterhorn.Core.W
import Wetterhorn.Keys.Macros
import Wetterhorn.Layout.Full

config :: Config WindowLayout
config =
  defaultConfig
    { hooks =
        defaultHooks
          { surfaceHook = do
              handleSurface
          },
      layout = WindowLayout Full,
      resetHook = do
        useKeysWithContinuation recordMacroContinuation $ do
          ev <- nextButtonOrKeyPress

          case ev of
            Right kp -> do
              bind kp (Mod1 .+ 'q') macroKeyBind

              bind kp (weak $ Mod1 .+ '@') replayMacroKeybind

              bind kp (Mod1 .+ 'r') (shellExec "wofi --show run")

              bind kp (Shift .+ Mod1 .+ 'R') requestHotReload

              bind kp (Mod1 .+ 't') (shellExec "alacritty")

              bind kp (Mod1 .+ 'n') (return () :: W ())

              bind kp (weak $ Mod1 .+ '∫') (shellExec "gxmessage hi")

              bind kp (Mod1 .+ 'p') $ do
                str <-
                  unfoldM
                    ( do
                        ke <- nextKeyPress
                        return $
                          if KeyEvent.codepoint ke == '\r'
                            then Nothing
                            else Just (KeyEvent.codepoint ke)
                    )
                liftIO $ putStrLn $ "You input: " ++ str
                bind kp (str == "hello") $ do
                  wio $ putStrLn "You Win! *\\o/*"
                liftIO $ putStrLn "You lose :("

              forwardEvent kp

            Left but ->
              liftIO $ putStrLn $ "ButtonEvent! " ++ (show but)
    }