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 ...@@ -3,4 +3,4 @@ module Main where
import QBar.Cli import QBar.Cli
main :: IO () main :: IO ()
main = runQBar main = runQBar
\ No newline at end of file
...@@ -52,12 +52,11 @@ getBatteryState path = tryMaybe $ do ...@@ -52,12 +52,11 @@ getBatteryState path = tryMaybe $ do
batteryBlock :: PullBlock batteryBlock :: PullBlock
batteryBlock = do batteryBlock = forever $ do
batteryPaths <- liftIO $ map ((apiPath <> "/") <>) . filter (T.isPrefixOf "BAT" . T.pack) <$> getDirectoryContents apiPath batteryPaths <- liftIO $ map ((apiPath <> "/") <>) . filter (T.isPrefixOf "BAT" . T.pack) <$> getDirectoryContents apiPath
batteryStates <- liftIO $ mapM getBatteryState batteryPaths batteryStates <- liftIO $ mapM getBatteryState batteryPaths
isPlugged <- liftIO getPluggedState isPlugged <- liftIO getPluggedState
updateBatteryBlock isPlugged $ catMaybes batteryStates updateBatteryBlock isPlugged $ catMaybes batteryStates
batteryBlock
where where
apiPath :: FilePath apiPath :: FilePath
apiPath = "/sys/class/power_supply" apiPath = "/sys/class/power_supply"
......
...@@ -11,10 +11,9 @@ import Control.Lens ...@@ -11,10 +11,9 @@ import Control.Lens
dateBlock :: PushBlock dateBlock :: PushBlock
dateBlock = do dateBlock = forever $ do
updateBlock =<< liftIO dateBlockOutput updateBlock =<< liftIO dateBlockOutput
liftIO $ sleepUntil =<< nextMinute sleepUntilInterval everyMinute
dateBlock
dateBlockOutput :: IO BlockOutput 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