ENH generalize backlight common plugin
This commit is contained in:
parent
cc0465194a
commit
6738f8a4c7
|
@ -7,20 +7,21 @@
|
|||
module Xmobar.Plugins.BacklightCommon (startBacklight) where
|
||||
|
||||
import Data.Internal.DBus
|
||||
import RIO
|
||||
import qualified RIO.Text as T
|
||||
import Xmobar.Plugins.Common
|
||||
|
||||
startBacklight
|
||||
:: RealFrac a
|
||||
=> ((Maybe a -> IO ()) -> SesClient -> IO ())
|
||||
-> (SesClient -> IO (Maybe a))
|
||||
:: (MonadUnliftIO m, RealFrac a)
|
||||
=> ((Maybe a -> m ()) -> SesClient -> m ())
|
||||
-> (SesClient -> m (Maybe a))
|
||||
-> T.Text
|
||||
-> Callback
|
||||
-> IO ()
|
||||
-> m ()
|
||||
startBacklight matchSignal callGetBrightness icon cb = do
|
||||
withDBusClientConnection cb $ \c -> do
|
||||
matchSignal display c
|
||||
display =<< callGetBrightness c
|
||||
matchSignal dpy c
|
||||
dpy =<< callGetBrightness c
|
||||
where
|
||||
formatBrightness b = return $ T.concat [icon, T.pack $ show (round b :: Integer), "%"]
|
||||
display = displayMaybe cb formatBrightness
|
||||
dpy = displayMaybe cb formatBrightness
|
||||
|
|
Loading…
Reference in New Issue