From 86d91d7032f2d8175fd1ab3b23ee0c1a6445fb7a Mon Sep 17 00:00:00 2001 From: Josh Rahm Date: Tue, 19 Mar 2024 17:40:37 -0600 Subject: Implementing button presses and integrating it with the KeysM monad. --- src/Config.hs | 51 ++++++++++++++++++++++++++++----------------------- 1 file changed, 28 insertions(+), 23 deletions(-) (limited to 'src/Config.hs') diff --git a/src/Config.hs b/src/Config.hs index e71f48a..5f09cbe 100644 --- a/src/Config.hs +++ b/src/Config.hs @@ -20,36 +20,41 @@ config = layout = WindowLayout Full, resetHook = do useKeysWithContinuation recordMacroContinuation $ do - kp <- nextKeyPress + ev <- nextButtonOrKeyPress - bind kp (Mod1 .+ 'q') macroKeyBind + case ev of + Right kp -> do + bind kp (Mod1 .+ 'q') macroKeyBind - bind kp (weak $ Mod1 .+ '@') replayMacroKeybind + bind kp (weak $ Mod1 .+ '@') replayMacroKeybind - bind kp (Mod1 .+ 'r') (shellExec "wofi --show run") + bind kp (Mod1 .+ 'r') (shellExec "wofi --show run") - bind kp (Shift .+ Mod1 .+ 'R') requestHotReload + bind kp (Shift .+ Mod1 .+ 'R') requestHotReload - bind kp (Mod1 .+ 't') (shellExec "alacritty") + bind kp (Mod1 .+ 't') (shellExec "alacritty") - bind kp (Mod1 .+ 'n') (return () :: W ()) + bind kp (Mod1 .+ 'n') (return () :: W ()) - bind kp (weak $ Mod1 .+ '∫') (shellExec "gxmessage hi") + 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 :(" + 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 + forwardEvent kp + + Left but -> + liftIO $ putStrLn $ "ButtonEvent! " ++ (show but) } -- cgit