Created
June 17, 2011 15:39
-
-
Save kreed131/1031663 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{- | |
Depends on scrot. | |
shootMe <directory to save images> <period> | |
Using: | |
ghc -o shootMe ShootMe.hs; | |
shootMe /home/user/images/screenshots/auto/ 60 & | |
-} | |
import Control.Concurrent (threadDelay) | |
import System (system, getArgs) | |
import Data.DateTime | |
import Data.List (isPrefixOf, intercalate) | |
-- you should send "dir" then "minutes" | |
main :: IO a | |
main = do | |
args <- getArgs | |
let dir = head args | |
let period = (read (args !! 1) :: Int) * 60 | |
waitFor 300 | |
shootMe dir period | |
shootMe :: String -> Int -> IO a | |
shootMe dir period = do | |
t <- fmap (show . toClockTime) getCurrentTime | |
let imageName = intercalate "_" (filter (not . isPrefixOf "EE") $ words t) ++ ".png" | |
let execName = "scrot -q 100 " ++ dir ++ imageName | |
system execName | |
waitFor period | |
shootMe dir period | |
waitFor = threadDelay . (* 1000000) --seconds |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment