From ab73c24f7581713e23e988b1c563838ff97d8006 Mon Sep 17 00:00:00 2001 From: ndwarshuis Date: Sat, 21 Mar 2020 14:46:49 -0400 Subject: [PATCH] FIX increase threaddelay to avoid using cpu as space heater --- lib/Xmobar/Plugins/Bluetooth.hs | 13 ++++--------- lib/Xmobar/Plugins/IntelBacklight.hs | 2 +- lib/Xmobar/Plugins/Screensaver.hs | 2 +- 3 files changed, 6 insertions(+), 11 deletions(-) diff --git a/lib/Xmobar/Plugins/Bluetooth.hs b/lib/Xmobar/Plugins/Bluetooth.hs index 9184d2a..c66fbb3 100644 --- a/lib/Xmobar/Plugins/Bluetooth.hs +++ b/lib/Xmobar/Plugins/Bluetooth.hs @@ -46,13 +46,10 @@ instance Exec Bluetooth where reply <- callBT client -- TODO handle errors? case reply of - Right ret -> cb - $ fmtState - $ fromVariant - =<< fromVariant + Right ret -> cb $ fmtState $ fromVariant =<< fromVariant =<< listToMaybe (methodReturnBody ret) Left _ -> return () - forever (threadDelay 5000) + forever (threadDelay 5000000) where -- Assume that the data in the PropertiesChanged signal has the form -- [something, Map, something] where the Map in the middle has the @@ -61,10 +58,8 @@ instance Exec Bluetooth where getProps = \case [_, Variant (ValueMap TypeString TypeVariant m), _] -> Just m _ -> Nothing - lookupState m = fromVariant - =<< fromValue - =<< M.lookup (AtomText "Powered") - =<< m + lookupState m = fromVariant =<< fromValue + =<< M.lookup (AtomText "Powered") =<< m fmtState = \case Just s -> wrapColor text $ if s then colorOn else colorOff Nothing -> "N/A" diff --git a/lib/Xmobar/Plugins/IntelBacklight.hs b/lib/Xmobar/Plugins/IntelBacklight.hs index 2f696b3..caa3224 100644 --- a/lib/Xmobar/Plugins/IntelBacklight.hs +++ b/lib/Xmobar/Plugins/IntelBacklight.hs @@ -16,7 +16,7 @@ instance Exec IntelBacklight where start (IntelBacklight icon) cb = do _ <- matchSignal $ cb . formatBrightness cb . formatBrightness =<< callGetBrightness - forever (threadDelay 5000) + forever (threadDelay 5000000) where formatBrightness = \case Just b -> icon ++ show (b `div` 100) ++ "%" diff --git a/lib/Xmobar/Plugins/Screensaver.hs b/lib/Xmobar/Plugins/Screensaver.hs index 109e428..cdc1ce1 100644 --- a/lib/Xmobar/Plugins/Screensaver.hs +++ b/lib/Xmobar/Plugins/Screensaver.hs @@ -17,7 +17,7 @@ instance Exec Screensaver where start (Screensaver (text, colorOn, colorOff)) cb = do _ <- matchSignal $ cb . fmtState cb . fmtState =<< callQuery - forever (threadDelay 5000) + forever (threadDelay 5000000) where fmtState = \case Just s -> wrapColor text $ if s then colorOn else colorOff