ENH use plugin name in xmobar loggers
This commit is contained in:
parent
cc094bb071
commit
69ed4839da
|
@ -13,13 +13,14 @@ import Xmobar.Plugins.Common
|
||||||
|
|
||||||
startBacklight
|
startBacklight
|
||||||
:: (MonadUnliftIO m, RealFrac a)
|
:: (MonadUnliftIO m, RealFrac a)
|
||||||
=> ((Maybe a -> RIO SimpleApp ()) -> SesClient -> RIO SimpleApp ())
|
=> Utf8Builder
|
||||||
|
-> ((Maybe a -> RIO SimpleApp ()) -> SesClient -> RIO SimpleApp ())
|
||||||
-> (SesClient -> RIO SimpleApp (Maybe a))
|
-> (SesClient -> RIO SimpleApp (Maybe a))
|
||||||
-> T.Text
|
-> T.Text
|
||||||
-> Callback
|
-> Callback
|
||||||
-> m ()
|
-> m ()
|
||||||
startBacklight matchSignal callGetBrightness icon cb = do
|
startBacklight name matchSignal callGetBrightness icon cb = do
|
||||||
withDBusClientConnection cb $ \c -> do
|
withDBusClientConnection cb name $ \c -> do
|
||||||
matchSignal dpy c
|
matchSignal dpy c
|
||||||
dpy =<< callGetBrightness c
|
dpy =<< callGetBrightness c
|
||||||
where
|
where
|
||||||
|
|
|
@ -65,7 +65,7 @@ data Bluetooth = Bluetooth Icons Colors deriving (Read, Show)
|
||||||
instance Exec Bluetooth where
|
instance Exec Bluetooth where
|
||||||
alias (Bluetooth _ _) = T.unpack btAlias
|
alias (Bluetooth _ _) = T.unpack btAlias
|
||||||
start (Bluetooth icons colors) cb =
|
start (Bluetooth icons colors) cb =
|
||||||
withDBusClientConnection cb $ startAdapter icons colors cb
|
withDBusClientConnection cb "bluetooth" $ startAdapter icons colors cb
|
||||||
|
|
||||||
startAdapter
|
startAdapter
|
||||||
:: (MonadReader env m, HasLogFunc env, MonadUnliftIO m)
|
:: (MonadReader env m, HasLogFunc env, MonadUnliftIO m)
|
||||||
|
|
|
@ -25,4 +25,4 @@ ckAlias = "clevokeyboard"
|
||||||
instance Exec ClevoKeyboard where
|
instance Exec ClevoKeyboard where
|
||||||
alias (ClevoKeyboard _) = T.unpack ckAlias
|
alias (ClevoKeyboard _) = T.unpack ckAlias
|
||||||
start (ClevoKeyboard icon) =
|
start (ClevoKeyboard icon) =
|
||||||
startBacklight matchSignalCK callGetBrightnessCK icon
|
startBacklight "clevo keyboard" matchSignalCK callGetBrightnessCK icon
|
||||||
|
|
|
@ -70,6 +70,13 @@ displayMaybe' cb = maybe (liftIO $ cb $ T.unpack na)
|
||||||
withDBusClientConnection
|
withDBusClientConnection
|
||||||
:: (MonadUnliftIO m, SafeClient c)
|
:: (MonadUnliftIO m, SafeClient c)
|
||||||
=> Callback
|
=> Callback
|
||||||
|
-> Utf8Builder
|
||||||
-> (c -> RIO SimpleApp ())
|
-> (c -> RIO SimpleApp ())
|
||||||
-> m ()
|
-> m ()
|
||||||
withDBusClientConnection cb f = runSimpleApp $ displayMaybe' cb f =<< getDBusClient
|
withDBusClientConnection cb name f = do
|
||||||
|
logOpts <- setLogVerboseFormat True . setLogUseTime True . setLogFormat pre <$> logOptionsHandle stderr False
|
||||||
|
withLogFunc logOpts $ \lf -> do
|
||||||
|
env <- mkSimpleApp lf Nothing
|
||||||
|
runRIO env $ displayMaybe' cb f =<< getDBusClient
|
||||||
|
where
|
||||||
|
pre rest = "[" <> name <> " plugin] " <> rest
|
||||||
|
|
|
@ -67,11 +67,12 @@ matchStatus = matchPropertyChanged nmDeviceInterface devSignal
|
||||||
|
|
||||||
instance Exec Device where
|
instance Exec Device where
|
||||||
alias (Device (iface, _, _)) = T.unpack iface
|
alias (Device (iface, _, _)) = T.unpack iface
|
||||||
start (Device (iface, text, colors)) cb = do
|
start (Device (iface, text, colors)) cb =
|
||||||
withDBusClientConnection cb $ \sys -> do
|
withDBusClientConnection cb logName $ \sys -> do
|
||||||
path <- getDevice sys iface
|
path <- getDevice sys iface
|
||||||
displayMaybe' cb (listener sys) path
|
displayMaybe' cb (listener sys) path
|
||||||
where
|
where
|
||||||
|
logName = "device@" <> Utf8Builder (encodeUtf8Builder iface)
|
||||||
listener sys path = do
|
listener sys path = do
|
||||||
rule <- matchPropertyFull sys networkManagerBus (Just path)
|
rule <- matchPropertyFull sys networkManagerBus (Just path)
|
||||||
-- TODO warn the user here rather than silently drop the listener
|
-- TODO warn the user here rather than silently drop the listener
|
||||||
|
|
|
@ -25,4 +25,4 @@ blAlias = "intelbacklight"
|
||||||
instance Exec IntelBacklight where
|
instance Exec IntelBacklight where
|
||||||
alias (IntelBacklight _) = T.unpack blAlias
|
alias (IntelBacklight _) = T.unpack blAlias
|
||||||
start (IntelBacklight icon) =
|
start (IntelBacklight icon) =
|
||||||
startBacklight matchSignalIB callGetBrightnessIB icon
|
startBacklight "intel backlight" matchSignalIB callGetBrightnessIB icon
|
||||||
|
|
|
@ -24,9 +24,9 @@ ssAlias = "screensaver"
|
||||||
|
|
||||||
instance Exec Screensaver where
|
instance Exec Screensaver where
|
||||||
alias (Screensaver _) = T.unpack ssAlias
|
alias (Screensaver _) = T.unpack ssAlias
|
||||||
start (Screensaver (text, colors)) cb = do
|
start (Screensaver (text, colors)) cb =
|
||||||
withDBusClientConnection cb $ \sys -> do
|
withDBusClientConnection cb "screensaver" $ \sys -> do
|
||||||
matchSignal display sys
|
matchSignal dpy sys
|
||||||
display =<< callQuery sys
|
dpy =<< callQuery sys
|
||||||
where
|
where
|
||||||
display = displayMaybe cb $ return . (\s -> colorText colors s text)
|
dpy = displayMaybe cb $ return . (\s -> colorText colors s text)
|
||||||
|
|
|
@ -31,7 +31,7 @@ newtype VPN = VPN (T.Text, Colors) deriving (Read, Show)
|
||||||
instance Exec VPN where
|
instance Exec VPN where
|
||||||
alias (VPN _) = T.unpack vpnAlias
|
alias (VPN _) = T.unpack vpnAlias
|
||||||
start (VPN (text, colors)) cb =
|
start (VPN (text, colors)) cb =
|
||||||
withDBusClientConnection cb $ \c -> do
|
withDBusClientConnection cb "VPN" $ \c -> do
|
||||||
state <- initState c
|
state <- initState c
|
||||||
let dpy = displayMaybe cb iconFormatter . Just =<< readState state
|
let dpy = displayMaybe cb iconFormatter . Just =<< readState state
|
||||||
let signalCallback' f = f state dpy
|
let signalCallback' f = f state dpy
|
||||||
|
|
Loading…
Reference in New Issue