ADD default command to features

This commit is contained in:
Nathan Dwarshuis 2021-11-11 23:52:01 -05:00
parent 052937867b
commit 0caefb336f
5 changed files with 13 additions and 2 deletions

View File

@ -314,6 +314,7 @@ getBattery :: BarFeature
getBattery = Feature
{ ftrAction = batteryCmd
, ftrSilent = False
, ftrDefault = Nothing
, ftrChildren = [Dependency { depRequired = True, depData = IOTest hasBattery }]
}
@ -323,6 +324,7 @@ getVPN :: BarFeature
getVPN = Feature
{ ftrAction = vpnCmd
, ftrSilent = False
, ftrDefault = Nothing
, ftrChildren = [d, v]
}
where
@ -333,6 +335,7 @@ getBt :: BarFeature
getBt = Feature
{ ftrAction = btCmd
, ftrSilent = False
, ftrDefault = Nothing
, ftrChildren = [dep]
}
where
@ -341,6 +344,7 @@ getBt = Feature
getAlsa :: BarFeature
getAlsa = Feature
{ ftrAction = alsaCmd
, ftrDefault = Nothing
, ftrSilent = False
, ftrChildren = [exe "alsactl"]
}
@ -348,6 +352,7 @@ getAlsa = Feature
getBl :: BarFeature
getBl = Feature
{ ftrAction = blCmd
, ftrDefault = Nothing
, ftrSilent = False
, ftrChildren = [curFileDep, maxFileDep]
}
@ -355,6 +360,7 @@ getBl = Feature
getSs :: BarFeature
getSs = Feature
{ ftrAction = ssCmd
, ftrDefault = Nothing
, ftrSilent = False
, ftrChildren = [ssDep]
}

View File

@ -96,6 +96,7 @@ runTMux :: IO MaybeX
runTMux = evalFeature $ Feature
{ ftrAction = cmd
, ftrSilent = False
, ftrDefault = Nothing
, ftrChildren = [exe myTerm, exe "tmux", exe "bash"]
}
where

View File

@ -102,6 +102,7 @@ brightnessExporter :: RealFrac b => [Dependency (IO ())]
-> BrightnessConfig a b -> Client -> Feature (IO ()) (IO ())
brightnessExporter deps bc client = Feature
{ ftrAction = exportBrightnessControls' bc client
, ftrDefault = Nothing
, ftrSilent = False
, ftrChildren = deps
}
@ -137,6 +138,7 @@ callBacklight :: BrightnessConfig a b -> Feature (IO ()) (IO ()) -> MemberName
callBacklight BrightnessConfig { bcPath = p, bcInterface = i } exporter mem =
Feature
{ ftrAction = void $ callMethod $ methodCall p i mem
, ftrDefault = Nothing
, ftrSilent = False
, ftrChildren = [SubFeature exporter]
}

View File

@ -109,6 +109,7 @@ exportScreensaver client = initControls client exportScreensaver' controls
exportScreensaver' :: Client -> Feature (IO ()) (IO ())
exportScreensaver' client = Feature
{ ftrAction = cmd
, ftrDefault = Nothing
, ftrSilent = False
, ftrChildren = [ssDep]
}
@ -124,6 +125,7 @@ exportScreensaver' client = Feature
callToggle :: Feature (IO ()) (IO ()) -> Feature (IO ()) (IO ())
callToggle exporter = Feature
{ ftrAction = cmd
, ftrDefault = Nothing
, ftrSilent = False
, ftrChildren = [SubFeature exporter]
}

View File

@ -91,9 +91,8 @@ data Dependency a = SubFeature (Feature a a)
data Feature a b = Feature
{ ftrAction :: a
-- TODO add a 'default' action that will proceed in case of failure
, ftrDefault :: Maybe a
, ftrSilent :: Bool
-- TODO this should be a semigroup
, ftrChildren :: [Dependency b]
} | ConstFeature a
@ -250,6 +249,7 @@ runIfInstalled :: [Dependency a] -> b -> IO (MaybeExe b)
runIfInstalled ds x = evalFeature $
Feature
{ ftrAction = x
, ftrDefault = Nothing
, ftrSilent = False
, ftrChildren = ds
}