Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- module Main where
- import System.Environment ( getArgs )
- import System.FSNotify
- import System.FilePath.Posix ( takeFileName )
- import System.Process ( spawnProcess )
- import Control.Monad ( forever, void )
- import Control.Concurrent ( threadDelay )
- main :: IO ()
- main = withManager $ \mgr -> do
- args <- getArgs
- let exe = head args
- files = tail args
- watchDir mgr "." (modified files) (action exe files)
- forever $ threadDelay 1000000
- where
- modified :: [FilePath] -> Event -> Bool
- modified files (Modified path _ False) = (takeFileName path) `elem` files
- modified _ _ = False
- action :: FilePath -> [FilePath] -> Event -> IO ()
- action proc files ev = do
- print ev
- putStrLn $ "calling " <> show proc <> " with " <> show files
- void $ spawnProcess proc files
- watchConf :: WatchConfig
- watchConf = defaultConfig { confDebounce = Debounce 50 }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement