module System.Taffybar.DBus
  ( module System.Taffybar.DBus.Toggle
  , appendHook
  , startTaffyLogServer
  , withLogServer
  , withToggleServer
  ) where

import Control.Monad.Trans.Class
import Control.Monad.Trans.Reader
import System.Log.DBus.Server
import System.Taffybar.Context
import System.Taffybar.DBus.Toggle

startTaffyLogServer :: TaffyIO ()
startTaffyLogServer :: TaffyIO ()
startTaffyLogServer =
  (Context -> Client) -> ReaderT Context IO Client
forall (m :: * -> *) r a. Monad m => (r -> a) -> ReaderT r m a
asks Context -> Client
sessionDBusClient ReaderT Context IO Client -> (Client -> TaffyIO ()) -> TaffyIO ()
forall a b.
ReaderT Context IO a
-> (a -> ReaderT Context IO b) -> ReaderT Context IO b
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= IO () -> TaffyIO ()
forall (m :: * -> *) a. Monad m => m a -> ReaderT Context m a
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (IO () -> TaffyIO ()) -> (Client -> IO ()) -> Client -> TaffyIO ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Client -> IO ()
startLogServer

withLogServer :: TaffybarConfig -> TaffybarConfig
withLogServer :: TaffybarConfig -> TaffybarConfig
withLogServer = TaffyIO () -> TaffybarConfig -> TaffybarConfig
appendHook TaffyIO ()
startTaffyLogServer

withToggleServer :: TaffybarConfig -> TaffybarConfig
withToggleServer :: TaffybarConfig -> TaffybarConfig
withToggleServer = TaffybarConfig -> TaffybarConfig
handleDBusToggles