FIX increase threaddelay to avoid using cpu as space heater

This commit is contained in:
Nathan Dwarshuis 2020-03-21 14:46:49 -04:00
parent 90140fef5d
commit ab73c24f75
3 changed files with 6 additions and 11 deletions

View File

@ -46,13 +46,10 @@ instance Exec Bluetooth where
reply <- callBT client reply <- callBT client
-- TODO handle errors? -- TODO handle errors?
case reply of case reply of
Right ret -> cb Right ret -> cb $ fmtState $ fromVariant =<< fromVariant
$ fmtState
$ fromVariant
=<< fromVariant
=<< listToMaybe (methodReturnBody ret) =<< listToMaybe (methodReturnBody ret)
Left _ -> return () Left _ -> return ()
forever (threadDelay 5000) forever (threadDelay 5000000)
where where
-- Assume that the data in the PropertiesChanged signal has the form -- Assume that the data in the PropertiesChanged signal has the form
-- [something, Map, something] where the Map in the middle has the -- [something, Map, something] where the Map in the middle has the
@ -61,10 +58,8 @@ instance Exec Bluetooth where
getProps = \case getProps = \case
[_, Variant (ValueMap TypeString TypeVariant m), _] -> Just m [_, Variant (ValueMap TypeString TypeVariant m), _] -> Just m
_ -> Nothing _ -> Nothing
lookupState m = fromVariant lookupState m = fromVariant =<< fromValue
=<< fromValue =<< M.lookup (AtomText "Powered") =<< m
=<< M.lookup (AtomText "Powered")
=<< m
fmtState = \case fmtState = \case
Just s -> wrapColor text $ if s then colorOn else colorOff Just s -> wrapColor text $ if s then colorOn else colorOff
Nothing -> "N/A" Nothing -> "N/A"

View File

@ -16,7 +16,7 @@ instance Exec IntelBacklight where
start (IntelBacklight icon) cb = do start (IntelBacklight icon) cb = do
_ <- matchSignal $ cb . formatBrightness _ <- matchSignal $ cb . formatBrightness
cb . formatBrightness =<< callGetBrightness cb . formatBrightness =<< callGetBrightness
forever (threadDelay 5000) forever (threadDelay 5000000)
where where
formatBrightness = \case formatBrightness = \case
Just b -> icon ++ show (b `div` 100) ++ "%" Just b -> icon ++ show (b `div` 100) ++ "%"

View File

@ -17,7 +17,7 @@ instance Exec Screensaver where
start (Screensaver (text, colorOn, colorOff)) cb = do start (Screensaver (text, colorOn, colorOff)) cb = do
_ <- matchSignal $ cb . fmtState _ <- matchSignal $ cb . fmtState
cb . fmtState =<< callQuery cb . fmtState =<< callQuery
forever (threadDelay 5000) forever (threadDelay 5000000)
where where
fmtState = \case fmtState = \case
Just s -> wrapColor text $ if s then colorOn else colorOff Just s -> wrapColor text $ if s then colorOn else colorOff