ENH use bracket for request/release busname
This commit is contained in:
parent
8c20a4668d
commit
4951c2a35e
|
@ -89,7 +89,7 @@ run = do
|
||||||
uninstallSignalHandlers
|
uninstallSignalHandlers
|
||||||
hSetBuffering stdout LineBuffering
|
hSetBuffering stdout LineBuffering
|
||||||
withCache $ do
|
withCache $ do
|
||||||
withDBusX $ \db -> do
|
withDBusX_ $ \db -> do
|
||||||
let sys = dbSysClient db
|
let sys = dbSysClient db
|
||||||
let fs = features sys
|
let fs = features sys
|
||||||
startDBusInterfaces db fs
|
startDBusInterfaces db fs
|
||||||
|
@ -204,12 +204,12 @@ startXmobar = do
|
||||||
startChildDaemons :: FeatureSet -> FIO [Process () () ()]
|
startChildDaemons :: FeatureSet -> FIO [Process () () ()]
|
||||||
startChildDaemons fs = catMaybes <$> mapM executeSometimes (fsDaemons fs)
|
startChildDaemons fs = catMaybes <$> mapM executeSometimes (fsDaemons fs)
|
||||||
|
|
||||||
withDBusX :: (DBusState -> FIO a) -> FIO a
|
-- withDBusX :: (DBusState -> FIO a) -> FIO a
|
||||||
withDBusX = bracket (io connectDBusX) cleanup
|
-- withDBusX = bracket (io connectDBusX) cleanup
|
||||||
where
|
-- where
|
||||||
cleanup db = do
|
-- cleanup db = do
|
||||||
logInfo "unregistering xmonad from DBus"
|
-- logInfo "unregistering xmonad from DBus"
|
||||||
io $ disconnectDBus db
|
-- io $ disconnectDBus db
|
||||||
|
|
||||||
withChildDaemons :: FeatureSet -> ([Process () () ()] -> FIO a) -> FIO a
|
withChildDaemons :: FeatureSet -> ([Process () () ()] -> FIO a) -> FIO a
|
||||||
withChildDaemons fs = bracket (startChildDaemons fs) cleanup
|
withChildDaemons fs = bracket (startChildDaemons fs) cleanup
|
||||||
|
|
|
@ -6,6 +6,8 @@
|
||||||
module XMonad.Internal.DBus.Control
|
module XMonad.Internal.DBus.Control
|
||||||
( Client
|
( Client
|
||||||
, DBusState (..)
|
, DBusState (..)
|
||||||
|
, withDBusX
|
||||||
|
, withDBusX_
|
||||||
, withDBus
|
, withDBus
|
||||||
, withDBus_
|
, withDBus_
|
||||||
, connectDBus
|
, connectDBus
|
||||||
|
@ -36,6 +38,14 @@ data DBusState = DBusState
|
||||||
, dbSysClient :: Maybe SysClient
|
, dbSysClient :: Maybe SysClient
|
||||||
}
|
}
|
||||||
|
|
||||||
|
withDBusX_ :: MonadUnliftIO m => (DBusState -> m a) -> m ()
|
||||||
|
withDBusX_ = void . withDBusX
|
||||||
|
|
||||||
|
withDBusX :: MonadUnliftIO m => (DBusState -> m a) -> m (Maybe a)
|
||||||
|
withDBusX f = withDBus $ \db -> do
|
||||||
|
forM (dbSesClient db) $ \ses -> do
|
||||||
|
bracket_ (requestXMonadName ses) (releaseXMonadName ses) $ f db
|
||||||
|
|
||||||
withDBus_ :: MonadUnliftIO m => (DBusState -> m a) -> m ()
|
withDBus_ :: MonadUnliftIO m => (DBusState -> m a) -> m ()
|
||||||
withDBus_ = void . withDBus
|
withDBus_ = void . withDBus
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue