REF rename DBus types

This commit is contained in:
Nathan Dwarshuis 2021-11-21 23:59:38 -05:00
parent c03f1938a1
commit 8c4683faa1
5 changed files with 17 additions and 17 deletions

View File

@ -312,7 +312,7 @@ type BarFeature = Feature CmdSpec
getVPN :: Maybe Client -> BarFeature
getVPN client = Feature
{ ftrAction = DBusEndpoint_ (const vpnCmd) client [ep] [dp]
{ ftrAction = DBusEndpoint (const vpnCmd) client [ep] [dp]
, ftrName = "VPN status indicator"
, ftrWarning = Default
}
@ -322,7 +322,7 @@ getVPN client = Feature
getBt :: Maybe Client -> BarFeature
getBt client = Feature
{ ftrAction = DBusEndpoint_ (const btCmd) client [ep] []
{ ftrAction = DBusEndpoint (const btCmd) client [ep] []
, ftrName = "bluetooth status indicator"
, ftrWarning = Default
}
@ -338,21 +338,21 @@ getAlsa = Feature
getBl :: Maybe Client -> BarFeature
getBl client = Feature
{ ftrAction = DBusEndpoint_ (const blCmd) client [intelBacklightSignalDep] []
{ ftrAction = DBusEndpoint (const blCmd) client [intelBacklightSignalDep] []
, ftrName = "Intel backlight indicator"
, ftrWarning = Default
}
getCk :: Maybe Client -> BarFeature
getCk client = Feature
{ ftrAction = DBusEndpoint_ (const ckCmd) client [clevoKeyboardSignalDep] []
{ ftrAction = DBusEndpoint (const ckCmd) client [clevoKeyboardSignalDep] []
, ftrName = "Clevo keyboard indicator"
, ftrWarning = Default
}
getSs :: Maybe Client -> BarFeature
getSs client = Feature
{ ftrAction = DBusEndpoint_ (const ssCmd) client [ssSignalDep] []
{ ftrAction = DBusEndpoint (const ssCmd) client [ssSignalDep] []
, ftrName = "screensaver indicator"
, ftrWarning = Default
}

View File

@ -90,7 +90,7 @@ listenDevices = do
runRemovableMon :: Maybe Client -> FeatureIO
runRemovableMon client = Feature
{ ftrAction = DBusEndpoint_ (const listenDevices) client [addedDep, removedDep] []
{ ftrAction = DBusEndpoint (const listenDevices) client [addedDep, removedDep] []
, ftrName = "removeable device monitor"
, ftrWarning = Default
}

View File

@ -91,7 +91,7 @@ matchSignal BrightnessConfig { bcPath = p, bcInterface = i } cb = do
brightnessExporter :: RealFrac b => [Dependency] -> BrightnessConfig a b
-> Maybe Client -> FeatureIO
brightnessExporter deps bc@BrightnessConfig { bcName = n } client = Feature
{ ftrAction = DBusBus_ (exportBrightnessControls' bc) xmonadBusName client deps
{ ftrAction = DBusBus (exportBrightnessControls' bc) xmonadBusName client deps
, ftrName = n ++ " exporter"
, ftrWarning = Default
}

View File

@ -95,7 +95,7 @@ bodyGetCurrentState _ = Nothing
exportScreensaver :: Maybe Client -> FeatureIO
exportScreensaver client = Feature
{ ftrAction = DBusBus_ cmd xmonadBusName client [Executable ssExecutable]
{ ftrAction = DBusBus cmd xmonadBusName client [Executable ssExecutable]
, ftrName = "screensaver interface"
, ftrWarning = Default
}

View File

@ -79,14 +79,14 @@ data Feature a = Feature
data Action a = Parent a [Dependency]
| forall b. Chain (b -> a) (IO (Either [String] b))
| DBusEndpoint_ (Client -> a) (Maybe Client) [Endpoint] [Dependency]
| DBusBus_ (Client -> a) BusName (Maybe Client) [Dependency]
| DBusEndpoint (Client -> a) (Maybe Client) [Endpoint] [Dependency]
| DBusBus (Client -> a) BusName (Maybe Client) [Dependency]
instance Functor Action where
fmap f (Parent a ds) = Parent (f a) ds
fmap f (Chain a b) = Chain (f . a) b
fmap f (DBusEndpoint_ a c es ds) = DBusEndpoint_ (f . a) c es ds
fmap f (DBusBus_ a b c eps) = DBusBus_ (f . a) b c eps
fmap f (DBusEndpoint a c es ds) = DBusEndpoint (f . a) c es ds
fmap f (DBusBus a b c eps) = DBusBus (f . a) b c eps
-- TODO this is silly as is, and could be made more useful by representing
-- loglevels
@ -121,7 +121,7 @@ featureExeArgs n cmd args =
featureEndpoint :: BusName -> ObjectPath -> InterfaceName -> MemberName
-> Maybe Client -> FeatureIO
featureEndpoint busname path iface mem client = Feature
{ ftrAction = DBusEndpoint_ cmd client deps []
{ ftrAction = DBusEndpoint cmd client deps []
, ftrName = "screensaver toggle"
, ftrWarning = Default
}
@ -150,16 +150,16 @@ evalAction (Parent a ds) = do
evalAction (Chain a b) = second a <$> b
evalAction (DBusEndpoint_ _ Nothing _ _) = return $ Left ["client not available"]
evalAction (DBusEndpoint_ action (Just client) es ds) = do
evalAction (DBusEndpoint _ Nothing _ _) = return $ Left ["client not available"]
evalAction (DBusEndpoint action (Just client) es ds) = do
eperrors <- mapM (endpointSatisfied client) es
dperrors <- mapM evalDependency ds
return $ case catMaybes (eperrors ++ dperrors) of
[] -> Right $ action client
es' -> Left es'
evalAction (DBusBus_ _ _ Nothing _) = return $ Left ["client not available"]
evalAction (DBusBus_ action busname (Just client) deps) = do
evalAction (DBusBus _ _ Nothing _) = return $ Left ["client not available"]
evalAction (DBusBus action busname (Just client) deps) = do
res <- busSatisfied client busname
es <- catMaybes . (res:) <$> mapM evalDependency deps
return $ case es of