ENH generalize brightness
This commit is contained in:
parent
e508f29bd8
commit
b9a10df606
|
@ -14,13 +14,12 @@ module XMonad.Internal.DBus.Brightness.Common
|
||||||
)
|
)
|
||||||
where
|
where
|
||||||
|
|
||||||
import Control.Monad (void)
|
|
||||||
import DBus
|
import DBus
|
||||||
import DBus.Client
|
import DBus.Client
|
||||||
import qualified DBus.Introspection as I
|
import qualified DBus.Introspection as I
|
||||||
import Data.Int (Int32)
|
|
||||||
import Data.Internal.DBus
|
import Data.Internal.DBus
|
||||||
import Data.Internal.Dependency
|
import Data.Internal.Dependency
|
||||||
|
import RIO
|
||||||
import qualified RIO.Text as T
|
import qualified RIO.Text as T
|
||||||
import XMonad.Core (io)
|
import XMonad.Core (io)
|
||||||
import XMonad.Internal.DBus.Common
|
import XMonad.Internal.DBus.Common
|
||||||
|
@ -69,10 +68,10 @@ brightnessControls q bc cl =
|
||||||
cb = callBacklight q cl bc
|
cb = callBacklight q cl bc
|
||||||
|
|
||||||
callGetBrightness
|
callGetBrightness
|
||||||
:: (SafeClient c, Num n)
|
:: (MonadUnliftIO m, SafeClient c, Num n)
|
||||||
=> BrightnessConfig a b
|
=> BrightnessConfig a b
|
||||||
-> c
|
-> c
|
||||||
-> IO (Maybe n)
|
-> m (Maybe n)
|
||||||
callGetBrightness BrightnessConfig {bcPath = p, bcInterface = i} client =
|
callGetBrightness BrightnessConfig {bcPath = p, bcInterface = i} client =
|
||||||
either (const Nothing) bodyGetBrightness
|
either (const Nothing) bodyGetBrightness
|
||||||
<$> callMethod client xmonadBusName p i memGet
|
<$> callMethod client xmonadBusName p i memGet
|
||||||
|
@ -82,11 +81,11 @@ signalDep BrightnessConfig {bcPath = p, bcInterface = i} =
|
||||||
Endpoint [] xmonadBusName p i $ Signal_ memCur
|
Endpoint [] xmonadBusName p i $ Signal_ memCur
|
||||||
|
|
||||||
matchSignal
|
matchSignal
|
||||||
:: (SafeClient c, Num n)
|
:: (MonadUnliftIO m, SafeClient c, Num n)
|
||||||
=> BrightnessConfig a b
|
=> BrightnessConfig a b
|
||||||
-> (Maybe n -> IO ())
|
-> (Maybe n -> m ())
|
||||||
-> c
|
-> c
|
||||||
-> IO ()
|
-> m ()
|
||||||
matchSignal BrightnessConfig {bcPath = p, bcInterface = i} cb =
|
matchSignal BrightnessConfig {bcPath = p, bcInterface = i} cb =
|
||||||
void . addMatchCallback brMatcher (cb . bodyGetBrightness)
|
void . addMatchCallback brMatcher (cb . bodyGetBrightness)
|
||||||
where
|
where
|
||||||
|
@ -148,9 +147,14 @@ exportBrightnessControls' bc cl = io $ do
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
||||||
emitBrightness :: RealFrac b => BrightnessConfig a b -> Client -> b -> IO ()
|
emitBrightness
|
||||||
|
:: (MonadUnliftIO m, RealFrac b)
|
||||||
|
=> BrightnessConfig a b
|
||||||
|
-> Client
|
||||||
|
-> b
|
||||||
|
-> m ()
|
||||||
emitBrightness BrightnessConfig {bcPath = p, bcInterface = i} client cur =
|
emitBrightness BrightnessConfig {bcPath = p, bcInterface = i} client cur =
|
||||||
emit client $ sig {signalBody = [toVariant (round cur :: Int32)]}
|
liftIO $ emit client $ sig {signalBody = [toVariant (round cur :: Int32)]}
|
||||||
where
|
where
|
||||||
sig = signal p i memCur
|
sig = signal p i memCur
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue