summaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
authorCorey Halpin <chalpin@cs.wisc.edu>2023-03-22 13:02:08 -0500
committerCorey Halpin <chalpin@cs.wisc.edu>2023-03-22 13:02:08 -0500
commitc42e88217a040080be8152bf419172b4642e4744 (patch)
treecbbcc127db9236f0706995e803dee20fcc355fb6 /src
parent6ffb81ca44d5003a98b9bd52661da61489a35866 (diff)
downloadxmobar-c42e88217a040080be8152bf419172b4642e4744.tar.gz
xmobar-c42e88217a040080be8152bf419172b4642e4744.tar.bz2
Handle SocketError when attempting to connect to dbus
Extends the solution from 8a53271cd6 to also handle SocketError, so that the process will not terminate. See also issue #537.
Diffstat (limited to 'src')
-rw-r--r--src/Xmobar/System/DBus.hs10
1 files changed, 6 insertions, 4 deletions
diff --git a/src/Xmobar/System/DBus.hs b/src/Xmobar/System/DBus.hs
index 103a5a9..90bee2a 100644
--- a/src/Xmobar/System/DBus.hs
+++ b/src/Xmobar/System/DBus.hs
@@ -1,3 +1,4 @@
+{-# LANGUAGE ScopedTypeVariables #-}
-----------------------------------------------------------------------------
-- |
-- Module : DBus
@@ -17,9 +18,10 @@ module Xmobar.System.DBus (runIPC) where
import DBus
import DBus.Client hiding (interfaceName)
import qualified DBus.Client as DC
+import DBus.Socket
import Data.Maybe (isNothing)
import Control.Concurrent.STM
-import Control.Exception (handle)
+import Control.Exception
import System.IO (stderr, hPutStrLn)
import Control.Monad.IO.Class (liftIO)
@@ -35,10 +37,10 @@ interfaceName :: InterfaceName
interfaceName = interfaceName_ "org.Xmobar.Control"
runIPC :: TMVar SignalType -> IO ()
-runIPC mvst = handle printException exportConnection
+runIPC mvst = exportConnection `catches` [
+ Handler(\ (ex :: ClientError) -> hPutStrLn stderr (clientErrorMessage ex)),
+ Handler(\ (ex :: SocketError) -> hPutStrLn stderr (socketErrorMessage ex))]
where
- printException :: ClientError -> IO ()
- printException = hPutStrLn stderr . clientErrorMessage
exportConnection = do
client <- connectSession
requestName client busName [ nameDoNotQueue ]