diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/Trivmix.hs | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/src/Trivmix.hs b/src/Trivmix.hs index 5dc213c..69fcea2 100644 --- a/src/Trivmix.hs +++ b/src/Trivmix.hs | |||
@@ -115,7 +115,8 @@ main = execParser opts >>= trivmix | |||
115 | trivmix :: Options -> IO () | 115 | trivmix :: Options -> IO () |
116 | trivmix Options{..} = do | 116 | trivmix Options{..} = do |
117 | level <- newMVar initialLevel | 117 | level <- newMVar initialLevel |
118 | withINotify $ \inotify -> do | 118 | let withFiles = foldl (.) id $ map (\f -> onStateFile f (show initialLevel ++ "\n")) levelFiles |
119 | withFiles $ withINotify $ \inotify -> do | ||
119 | handleFiles inotify level levelFiles | 120 | handleFiles inotify level levelFiles |
120 | Jack.handleExceptions $ | 121 | Jack.handleExceptions $ |
121 | Jack.withClientDefault client $ \client' -> | 122 | Jack.withClientDefault client $ \client' -> |
@@ -148,7 +149,7 @@ handleFiles inotify level files = do | |||
148 | forkIO $ forever $ do -- Broadcast level changes and update all files | 149 | forkIO $ forever $ do -- Broadcast level changes and update all files |
149 | readChan levelChanges' >>= writeLevel file | 150 | readChan levelChanges' >>= writeLevel file |
150 | addWatch inotify watchedAttrs file (const $ readLevel levelChanges level file) | 151 | addWatch inotify watchedAttrs file (const $ readLevel levelChanges level file) |
151 | sequence [onStateFile f (show initLevel ++ "\n") $ handleFile f | f <- files] | 152 | mapM handleFile files |
152 | forkIO $ forever $ do | 153 | forkIO $ forever $ do |
153 | readChan levelChanges >>= swapMVar level | 154 | readChan levelChanges >>= swapMVar level |
154 | return () | 155 | return () |