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

View File

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

View File

@ -91,7 +91,7 @@ matchSignal BrightnessConfig { bcPath = p, bcInterface = i } cb = do
brightnessExporter :: RealFrac b => [Dependency] -> BrightnessConfig a b brightnessExporter :: RealFrac b => [Dependency] -> BrightnessConfig a b
-> Maybe Client -> FeatureIO -> Maybe Client -> FeatureIO
brightnessExporter deps bc@BrightnessConfig { bcName = n } client = Feature 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" , ftrName = n ++ " exporter"
, ftrWarning = Default , ftrWarning = Default
} }

View File

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

View File

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