ENH generalize screensaver

This commit is contained in:
Nathan Dwarshuis 2022-12-31 20:23:27 -05:00
parent 7821140dc2
commit 39bd464ca1
1 changed files with 6 additions and 5 deletions

View File

@ -82,8 +82,9 @@ ruleCurrentState =
, matchMember = Just memState
}
emitState :: Client -> SSState -> IO ()
emitState client sss = emit client $ sigCurrentState {signalBody = [toVariant sss]}
emitState :: MonadUnliftIO m => Client -> SSState -> m ()
emitState client sss =
liftIO $ emit client $ sigCurrentState {signalBody = [toVariant sss]}
bodyGetCurrentState :: [Variant] -> Maybe SSState
bodyGetCurrentState [b] = fromVariant b :: Maybe SSState
@ -105,7 +106,7 @@ exportScreensaver ses =
defaultInterface
{ interfaceName = interface
, interfaceMethods =
[ autoMethod memToggle $ emitState cl' =<< toggle
[ autoMethod memToggle $ run $ emitState cl' =<< toggle
, autoMethod memQuery (run query)
]
, interfaceSignals = [sig]
@ -134,12 +135,12 @@ callToggle =
interface
memToggle
callQuery :: SesClient -> IO (Maybe SSState)
callQuery :: MonadUnliftIO m => SesClient -> m (Maybe SSState)
callQuery ses = do
reply <- callMethod ses xmonadBusName ssPath interface memQuery
return $ either (const Nothing) bodyGetCurrentState reply
matchSignal :: (Maybe SSState -> IO ()) -> SesClient -> IO ()
matchSignal :: MonadUnliftIO m => (Maybe SSState -> m ()) -> SesClient -> m ()
matchSignal cb ses =
void $
addMatchCallback