From c6f882fe85e3766464cc68d4edd2abe9bd08217a Mon Sep 17 00:00:00 2001 From: Josh Rahm Date: Fri, 18 Mar 2022 10:15:13 -0600 Subject: Ability to submap the mouse. Added bindings for my Logitech G502 Hero. --- src/Internal/Logger.hs | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 src/Internal/Logger.hs (limited to 'src/Internal/Logger.hs') diff --git a/src/Internal/Logger.hs b/src/Internal/Logger.hs new file mode 100644 index 0000000..f1960fb --- /dev/null +++ b/src/Internal/Logger.hs @@ -0,0 +1,36 @@ +module Internal.Logger where + +import XMonad +import qualified XMonad.Util.ExtensibleState as XS +import System.IO + +data LoggerState = + LoggerState { + logHandle :: Maybe Handle + } + +instance Read LoggerState where + readsPrec i s = map (\(_, s) -> (LoggerState Nothing, s)) (readsPrec i s :: [((), String)]) + +instance Show LoggerState where + show _ = show () + +instance ExtensionClass LoggerState where + initialValue = LoggerState Nothing + +logs :: String -> X () +logs s = do + LoggerState handle' <- XS.get + + handle <- + case handle' of + Nothing -> do + handle <- io $ openFile "/tmp/xmonad.log" AppendMode + XS.put $ LoggerState (Just handle) + return handle + + Just h -> return h + + io $ do + hPutStrLn handle s + hFlush handle -- cgit