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
-- 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"

View File

@ -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) ++ "%"

View File

@ -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