summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--src/IPC/DBus.hs16
1 files changed, 12 insertions, 4 deletions
diff --git a/src/IPC/DBus.hs b/src/IPC/DBus.hs
index b0597a4..469a7c6 100644
--- a/src/IPC/DBus.hs
+++ b/src/IPC/DBus.hs
@@ -14,10 +14,14 @@
module IPC.DBus ( runIPC ) where
+import Prelude hiding (catch)
+
import DBus
import DBus.Client
import Control.Monad (join, when)
import Control.Concurrent
+import Control.Exception (catch)
+import System.IO (stderr, hPutStrLn)
import Signal
import Plugins.Utils (safeHead)
@@ -32,10 +36,14 @@ interfaceName :: InterfaceName
interfaceName = interfaceName_ "org.Xmobar.Control"
runIPC :: MVar SignalType -> IO ()
-runIPC mvst = do
- client <- connectSession
- requestName client busName [ nameDoNotQueue ]
- export client objectPath [ sendSignalMethod mvst ]
+runIPC mvst = catch exportConnection printException
+ where
+ printException :: ClientError -> IO ()
+ printException = hPutStrLn stderr . clientErrorMessage
+ exportConnection = do
+ client <- connectSession
+ requestName client busName [ nameDoNotQueue ]
+ export client objectPath [ sendSignalMethod mvst ]
sendSignalMethod :: MVar SignalType -> Method
sendSignalMethod mvst = method interfaceName sendSignalName