Skip to content
Snippets Groups Projects
Commit 4000813b authored by Jens Nolte's avatar Jens Nolte
Browse files

Use forever

parent df583c4c
No related branches found
No related tags found
No related merge requests found
......@@ -3,4 +3,4 @@ module Main where
import QBar.Cli
main :: IO ()
main = runQBar
\ No newline at end of file
main = runQBar
......@@ -52,12 +52,11 @@ getBatteryState path = tryMaybe $ do
batteryBlock :: PullBlock
batteryBlock = do
batteryBlock = forever $ do
batteryPaths <- liftIO $ map ((apiPath <> "/") <>) . filter (T.isPrefixOf "BAT" . T.pack) <$> getDirectoryContents apiPath
batteryStates <- liftIO $ mapM getBatteryState batteryPaths
isPlugged <- liftIO getPluggedState
updateBatteryBlock isPlugged $ catMaybes batteryStates
batteryBlock
where
apiPath :: FilePath
apiPath = "/sys/class/power_supply"
......
......@@ -11,10 +11,9 @@ import Control.Lens
dateBlock :: PushBlock
dateBlock = do
dateBlock = forever $ do
updateBlock =<< liftIO dateBlockOutput
liftIO $ sleepUntil =<< nextMinute
dateBlock
sleepUntilInterval everyMinute
dateBlockOutput :: IO BlockOutput
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment