From d9b1886db63857981b22638e806d8a0f96c9dd81 Mon Sep 17 00:00:00 2001 From: ndwarshuis Date: Sat, 28 Oct 2023 00:14:40 -0400 Subject: [PATCH] FIX actually the dbus client disconnect problem --- lib/Xmobar/Plugins/Common.hs | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/lib/Xmobar/Plugins/Common.hs b/lib/Xmobar/Plugins/Common.hs index af657de..2295a81 100644 --- a/lib/Xmobar/Plugins/Common.hs +++ b/lib/Xmobar/Plugins/Common.hs @@ -110,9 +110,7 @@ withDBusClientConnection cb n logfile f = logOpts <- setLogVerboseFormat True . setLogUseTime True <$> logOptionsHandle h False withLogFunc logOpts $ \lf -> do env <- mkSimpleApp lf Nothing - runRIO env $ - bracket (getDBusClient n) (mapM (liftIO . disconnect . ncClient)) $ - displayMaybe' cb f + runRIO env $ displayMaybe' cb f =<< getDBusClient n -- | Run a plugin action with a new DBus client and logfile path. -- This is necessary for DBus callbacks which run in separate threads, which @@ -128,4 +126,9 @@ withNestedDBusClientConnection n logfile f = do dpy <- asks plugDisplay s <- asks plugState cb <- asks plugCallback - withDBusClientConnection cb n logfile $ \c -> mapRIO (PluginEnv c s dpy cb) f + let run h = do + logOpts <- setLogVerboseFormat True . setLogUseTime True <$> logOptionsHandle h False + withLogFunc logOpts $ \lf -> do + env <- mkSimpleApp lf Nothing + runRIO env $ withDBusClient_ n $ \cl -> mapRIO (PluginEnv cl s dpy cb) f + maybe (run stderr) (`withLogFile` run) logfile