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