FIX dbus not closing callback connections

This commit is contained in:
Nathan Dwarshuis 2023-10-27 23:57:40 -04:00
parent cc5670f2f1
commit 87eee7a2b9
3 changed files with 6 additions and 7 deletions

View File

@ -46,7 +46,7 @@ withDBusX
:: (MonadReader env m, HasLogFunc env, MonadUnliftIO m)
=> (DBusState -> m a)
-> m a
withDBusX = withDBus (Just xmonadSesBusName) (Just xmonadSysBusName)
withDBusX = withDBus (Just xmonadSesBusName) Nothing
withDBus_
:: (MonadReader env m, HasLogFunc env, MonadUnliftIO m)

View File

@ -54,11 +54,8 @@ data Bluetooth = Bluetooth Icons Colors deriving (Read, Show)
instance Exec Bluetooth where
alias (Bluetooth _ _) = T.unpack btAlias
start (Bluetooth icons colors) cb =
withDBusClientConnection
cb
(Just "org.xmonad.bluetooth")
(Just "bluetooth.log")
$ startAdapter icons colors cb
withDBusClientConnection cb Nothing (Just "bluetooth.log") $
startAdapter icons colors cb
startAdapter
:: Icons

View File

@ -110,7 +110,9 @@ withDBusClientConnection cb n logfile f =
logOpts <- setLogVerboseFormat True . setLogUseTime True <$> logOptionsHandle h False
withLogFunc logOpts $ \lf -> do
env <- mkSimpleApp lf Nothing
runRIO env $ displayMaybe' cb f =<< getDBusClient n
runRIO env $
bracket (getDBusClient n) (mapM (liftIO . disconnect . ncClient)) $
displayMaybe' cb f
-- | Run a plugin action with a new DBus client and logfile path.
-- This is necessary for DBus callbacks which run in separate threads, which