ENH generalize brightness controls

This commit is contained in:
Nathan Dwarshuis 2023-01-02 18:30:17 -05:00
parent 8eb97f3eec
commit 524818decf
4 changed files with 14 additions and 12 deletions

View File

@ -867,7 +867,7 @@ externalBindings runIO cleanup db =
where
ses = dbSesClient db
sys = dbSysClient db
brightessControls ctl getter = (getter . ctl) ses
brightessControls ctl getter = (fmap (liftIO . runIO) . getter . ctl) ses
ib = Left . brightessControls intelBacklightControls
ck = Left . brightessControls clevoKeyboardControls
ftrAlways n = Right . Always n . Always_ . FallbackAlone

View File

@ -126,7 +126,7 @@ exportClevoKeyboard =
[stateFileDep, brightnessFileDep]
clevoKeyboardConfig
clevoKeyboardControls :: Maybe SesClient -> BrightnessControls
clevoKeyboardControls :: MonadUnliftIO m => Maybe SesClient -> BrightnessControls m
clevoKeyboardControls = brightnessControls xpfClevoBacklight clevoKeyboardConfig
callGetBrightnessCK :: MonadUnliftIO m => SesClient -> m (Maybe Brightness)

View File

@ -45,18 +45,19 @@ data BrightnessConfig a b = BrightnessConfig
, bcName :: T.Text
}
data BrightnessControls = BrightnessControls
{ bctlMax :: SometimesX
, bctlMin :: SometimesX
, bctlInc :: SometimesX
, bctlDec :: SometimesX
data BrightnessControls m = BrightnessControls
{ bctlMax :: Sometimes (m ())
, bctlMin :: Sometimes (m ())
, bctlInc :: Sometimes (m ())
, bctlDec :: Sometimes (m ())
}
brightnessControls
:: XPQuery
:: MonadUnliftIO m
=> XPQuery
-> BrightnessConfig a b
-> Maybe SesClient
-> BrightnessControls
-> BrightnessControls m
brightnessControls q bc cl =
BrightnessControls
{ bctlMax = cb "max brightness" memMax
@ -167,12 +168,13 @@ emitBrightness BrightnessConfig {bcPath = p, bcInterface = i} client cur =
sig = signal p i memCur
callBacklight
:: XPQuery
:: MonadUnliftIO m
=> XPQuery
-> Maybe SesClient
-> BrightnessConfig a b
-> T.Text
-> MemberName
-> SometimesX
-> Sometimes (m ())
callBacklight
q
cl

View File

@ -110,7 +110,7 @@ exportIntelBacklight =
[curFileDep, maxFileDep]
intelBacklightConfig
intelBacklightControls :: Maybe SesClient -> BrightnessControls
intelBacklightControls :: MonadUnliftIO m => Maybe SesClient -> BrightnessControls m
intelBacklightControls = brightnessControls xpfIntelBacklight intelBacklightConfig
callGetBrightnessIB :: MonadUnliftIO m => SesClient -> m (Maybe Brightness)