Skip to content

Instantly share code, notes, and snippets.

@kreed131
Created June 17, 2011 15:39
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kreed131/1031663 to your computer and use it in GitHub Desktop.
Save kreed131/1031663 to your computer and use it in GitHub Desktop.
{-
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