2020-03-20 20:10:15 -04:00
|
|
|
{-# LANGUAGE OverloadedStrings #-}
|
|
|
|
|
|
|
|
module DBus.Internal where
|
|
|
|
|
|
|
|
import DBus
|
|
|
|
import DBus.Client
|
|
|
|
|
2020-03-20 23:47:02 -04:00
|
|
|
-- TODO not all methods warrent that we wait for a reply?
|
|
|
|
callMethod :: MethodCall -> IO (Maybe [Variant])
|
|
|
|
callMethod mc = do
|
|
|
|
client <- connectSession
|
2020-03-20 20:10:15 -04:00
|
|
|
-- TODO handle clienterrors here
|
|
|
|
reply <- call client mc { methodCallDestination = Just "org.xmonad" }
|
|
|
|
return $ case reply of
|
|
|
|
Left _ -> Nothing
|
|
|
|
Right ret -> Just $ methodReturnBody ret
|
|
|
|
|
|
|
|
addMatchCallback :: MatchRule -> ([Variant] -> IO ()) -> IO SignalHandler
|
|
|
|
addMatchCallback rule cb = do
|
|
|
|
client <- connectSession
|
|
|
|
addMatch client rule $ cb . signalBody
|