ENH use rio logger for eventhook

This commit is contained in:
Nathan Dwarshuis 2023-01-01 11:50:17 -05:00
parent 335fa7b460
commit 89eacd63aa
1 changed files with 17 additions and 7 deletions

View File

@ -136,7 +136,7 @@ run = do
, modMask = myModMask
, layoutHook = myLayouts tt
, manageHook = myManageHook dws
, handleEventHook = myEventHook ha
, handleEventHook = myEventHook runIO ha
, startupHook = myStartupHook
, workspaces = myWorkspaces
, logHook = myLoghook xmobarP
@ -625,20 +625,30 @@ manageApps dws =
--------------------------------------------------------------------------------
-- Eventhook configuration
myEventHook :: (String -> X ()) -> Event -> X All
myEventHook handler = xMsgEventHook handler <+> handleEventHook def
myEventHook
:: (MonadReader env m, HasLogFunc env, MonadUnliftIO m)
=> (m () -> IO ())
-> (String -> X ())
-> Event
-> X All
myEventHook runIO handler = xMsgEventHook runIO handler <+> handleEventHook def
-- | React to ClientMessage events from concurrent threads
xMsgEventHook :: (String -> X ()) -> Event -> X All
xMsgEventHook handler ClientMessageEvent {ev_message_type = t, ev_data = d}
xMsgEventHook
:: (MonadReader env m, HasLogFunc env, MonadUnliftIO m)
=> (m () -> IO ())
-> (String -> X ())
-> Event
-> X All
xMsgEventHook runIO handler ClientMessageEvent {ev_message_type = t, ev_data = d}
| t == bITMAP = do
let (xtype, tag) = splitXMsg d
case xtype of
Workspace -> removeDynamicWorkspace tag
ACPI -> handler tag
Unknown -> io $ putStrLn "WARNING: unknown concurrent message"
Unknown -> liftIO $ runIO $ logWarn "unknown concurrent message"
return (All True)
xMsgEventHook _ _ = return (All True)
xMsgEventHook _ _ _ = return (All True)
--------------------------------------------------------------------------------
-- Keymap configuration