Last active
June 19, 2018 21:20
-
-
Save jlafitte/b0a6e2bcd5edb2f80369 to your computer and use it in GitHub Desktop.
OS X Screenshot Script
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
<?xml version="1.0" encoding="UTF-8"?> | |
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> | |
<plist version="1.0"> | |
<dict> | |
<key>Label</key> | |
<string>me.screenshot</string> | |
<key>ProgramArguments</key> | |
<array> | |
<string>/Users/john/scripts/screenshot.sh</string> | |
</array> | |
<key>StartInterval</key> | |
<integer>60</integer> | |
<key>RunAtLoad</key> | |
<true/> | |
</dict> | |
</plist> |
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
#! /bin/bash | |
idleTime=60 | |
format=jpg | |
destination=$HOME/Desktop/Screenshots/ | |
if [ $((`ioreg -c IOHIDSystem | sed -e '/HIDIdleTime/ !{ d' -e 't' -e '}' -e 's/.* = //g' -e 'q'` / 1000000000)) -lt $idleTime ]; then | |
echo "taking screenshot" | |
foldername=""`eval date +%Y-%m-%d`"" | |
mkdir -p "$destination$foldername" | |
filename1="$destination/$foldername/image_01_"`eval date +%Y-%m-%d-%H-%M-%S`".$format" | |
# filename2="$destination/$foldername/image_02_"`eval date +%Y-%m-%d-%H-%M-%S`".$format" | |
screencapture -x -r -m -o -t $format "$filename1" | |
else | |
echo "idle - no screenshot" | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
launchctl load -w /Library/LaunchAgents/me.screenshot.plist