diff --git a/lib/Xmobar/Plugins/BacklightCommon.hs b/lib/Xmobar/Plugins/BacklightCommon.hs index 7605953..14c8e4c 100644 --- a/lib/Xmobar/Plugins/BacklightCommon.hs +++ b/lib/Xmobar/Plugins/BacklightCommon.hs @@ -13,13 +13,14 @@ import Xmobar.Plugins.Common startBacklight :: (MonadUnliftIO m, RealFrac a) - => ((Maybe a -> RIO SimpleApp ()) -> SesClient -> RIO SimpleApp ()) + => Utf8Builder + -> ((Maybe a -> RIO SimpleApp ()) -> SesClient -> RIO SimpleApp ()) -> (SesClient -> RIO SimpleApp (Maybe a)) -> T.Text -> Callback -> m () -startBacklight matchSignal callGetBrightness icon cb = do - withDBusClientConnection cb $ \c -> do +startBacklight name matchSignal callGetBrightness icon cb = do + withDBusClientConnection cb name $ \c -> do matchSignal dpy c dpy =<< callGetBrightness c where diff --git a/lib/Xmobar/Plugins/Bluetooth.hs b/lib/Xmobar/Plugins/Bluetooth.hs index 454401c..6f3c0c2 100644 --- a/lib/Xmobar/Plugins/Bluetooth.hs +++ b/lib/Xmobar/Plugins/Bluetooth.hs @@ -65,7 +65,7 @@ data Bluetooth = Bluetooth Icons Colors deriving (Read, Show) instance Exec Bluetooth where alias (Bluetooth _ _) = T.unpack btAlias start (Bluetooth icons colors) cb = - withDBusClientConnection cb $ startAdapter icons colors cb + withDBusClientConnection cb "bluetooth" $ startAdapter icons colors cb startAdapter :: (MonadReader env m, HasLogFunc env, MonadUnliftIO m) diff --git a/lib/Xmobar/Plugins/ClevoKeyboard.hs b/lib/Xmobar/Plugins/ClevoKeyboard.hs index 3f98f34..7c0f99f 100644 --- a/lib/Xmobar/Plugins/ClevoKeyboard.hs +++ b/lib/Xmobar/Plugins/ClevoKeyboard.hs @@ -25,4 +25,4 @@ ckAlias = "clevokeyboard" instance Exec ClevoKeyboard where alias (ClevoKeyboard _) = T.unpack ckAlias start (ClevoKeyboard icon) = - startBacklight matchSignalCK callGetBrightnessCK icon + startBacklight "clevo keyboard" matchSignalCK callGetBrightnessCK icon diff --git a/lib/Xmobar/Plugins/Common.hs b/lib/Xmobar/Plugins/Common.hs index 1983bba..aaabde7 100644 --- a/lib/Xmobar/Plugins/Common.hs +++ b/lib/Xmobar/Plugins/Common.hs @@ -70,6 +70,13 @@ displayMaybe' cb = maybe (liftIO $ cb $ T.unpack na) withDBusClientConnection :: (MonadUnliftIO m, SafeClient c) => Callback + -> Utf8Builder -> (c -> RIO SimpleApp ()) -> 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 diff --git a/lib/Xmobar/Plugins/Device.hs b/lib/Xmobar/Plugins/Device.hs index 220a297..9a81261 100644 --- a/lib/Xmobar/Plugins/Device.hs +++ b/lib/Xmobar/Plugins/Device.hs @@ -67,11 +67,12 @@ matchStatus = matchPropertyChanged nmDeviceInterface devSignal instance Exec Device where alias (Device (iface, _, _)) = T.unpack iface - start (Device (iface, text, colors)) cb = do - withDBusClientConnection cb $ \sys -> do + start (Device (iface, text, colors)) cb = + withDBusClientConnection cb logName $ \sys -> do path <- getDevice sys iface displayMaybe' cb (listener sys) path where + logName = "device@" <> Utf8Builder (encodeUtf8Builder iface) listener sys path = do rule <- matchPropertyFull sys networkManagerBus (Just path) -- TODO warn the user here rather than silently drop the listener diff --git a/lib/Xmobar/Plugins/IntelBacklight.hs b/lib/Xmobar/Plugins/IntelBacklight.hs index a4a777a..6174fba 100644 --- a/lib/Xmobar/Plugins/IntelBacklight.hs +++ b/lib/Xmobar/Plugins/IntelBacklight.hs @@ -25,4 +25,4 @@ blAlias = "intelbacklight" instance Exec IntelBacklight where alias (IntelBacklight _) = T.unpack blAlias start (IntelBacklight icon) = - startBacklight matchSignalIB callGetBrightnessIB icon + startBacklight "intel backlight" matchSignalIB callGetBrightnessIB icon diff --git a/lib/Xmobar/Plugins/Screensaver.hs b/lib/Xmobar/Plugins/Screensaver.hs index 70fa3c1..8c333b7 100644 --- a/lib/Xmobar/Plugins/Screensaver.hs +++ b/lib/Xmobar/Plugins/Screensaver.hs @@ -24,9 +24,9 @@ ssAlias = "screensaver" instance Exec Screensaver where alias (Screensaver _) = T.unpack ssAlias - start (Screensaver (text, colors)) cb = do - withDBusClientConnection cb $ \sys -> do - matchSignal display sys - display =<< callQuery sys + start (Screensaver (text, colors)) cb = + withDBusClientConnection cb "screensaver" $ \sys -> do + matchSignal dpy sys + dpy =<< callQuery sys where - display = displayMaybe cb $ return . (\s -> colorText colors s text) + dpy = displayMaybe cb $ return . (\s -> colorText colors s text) diff --git a/lib/Xmobar/Plugins/VPN.hs b/lib/Xmobar/Plugins/VPN.hs index 0de5391..9cc3f5a 100644 --- a/lib/Xmobar/Plugins/VPN.hs +++ b/lib/Xmobar/Plugins/VPN.hs @@ -31,7 +31,7 @@ newtype VPN = VPN (T.Text, Colors) deriving (Read, Show) instance Exec VPN where alias (VPN _) = T.unpack vpnAlias start (VPN (text, colors)) cb = - withDBusClientConnection cb $ \c -> do + withDBusClientConnection cb "VPN" $ \c -> do state <- initState c let dpy = displayMaybe cb iconFormatter . Just =<< readState state let signalCallback' f = f state dpy