diff options
| author | Josh Rahm <rahm@google.com> | 2022-03-18 10:15:13 -0600 |
|---|---|---|
| committer | Josh Rahm <joshuarahm@gmail.com> | 2022-10-09 12:19:45 -0600 |
| commit | f0b813ca548319d6ae6c95bd9a35db67223e00ae (patch) | |
| tree | 747b1c1b534db4815cac8fd0b1cd0f9c9ddc3110 /src/Internal/Logger.hs | |
| parent | c2201172d4b582cfc90a87cfe6a3a0c95cdea4e7 (diff) | |
| download | rde-f0b813ca548319d6ae6c95bd9a35db67223e00ae.tar.gz rde-f0b813ca548319d6ae6c95bd9a35db67223e00ae.tar.bz2 rde-f0b813ca548319d6ae6c95bd9a35db67223e00ae.zip | |
Ability to submap the mouse. Added bindings for my Logitech G502 Hero.
Diffstat (limited to 'src/Internal/Logger.hs')
| -rw-r--r-- | src/Internal/Logger.hs | 36 |
1 files changed, 36 insertions, 0 deletions
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 |