29 lines
878 B
Haskell
29 lines
878 B
Haskell
-- Common backlight plugin bits
|
|
--
|
|
-- Use the custom DBus interface exported by the XMonad process so I can react
|
|
-- to signals spawned by commands
|
|
module Xmobar.Plugins.BacklightCommon (startBacklight) where
|
|
|
|
import DBus
|
|
import Data.Internal.DBus
|
|
import RIO
|
|
import qualified RIO.Text as T
|
|
import Xmobar.Plugins.Common
|
|
|
|
startBacklight
|
|
:: (MonadUnliftIO m, RealFrac a)
|
|
=> Maybe BusName
|
|
-> Maybe FilePath
|
|
-> ((Maybe a -> DIO SimpleApp SesClient ()) -> DIO SimpleApp SesClient ())
|
|
-> DIO SimpleApp SesClient (Maybe a)
|
|
-> T.Text
|
|
-> Callback
|
|
-> m ()
|
|
startBacklight n name matchSignal callGetBrightness icon cb = do
|
|
withDBusClientConnection cb n name $ \c -> withDIO c $ do
|
|
matchSignal dpy
|
|
dpy =<< callGetBrightness
|
|
where
|
|
formatBrightness b = return $ T.concat [icon, T.pack $ show (round b :: Integer), "%"]
|
|
dpy = displayMaybe cb formatBrightness
|