Skip to content

Instantly share code, notes, and snippets.

@jpillora
Last active August 3, 2018 21:44
Show Gist options
  • Save jpillora/fc33261e08b563b59537 to your computer and use it in GitHub Desktop.
Save jpillora/fc33261e08b563b59537 to your computer and use it in GitHub Desktop.
Timeshot - Timesheet Screenshots

Timeshot

You can just run Timeshot in two ways:

  1. Execute timeshot.sh directly and leave your terminal window open in the foreground
  2. Load the timeshot.plist file to ensure it always runs in the background
  3. Change the WorkingDirectory to where your timeshot.sh is
  4. Copy timeshot.plist to ~/Library/LaunchAgents/timeshot.plist
  5. Execute launchctl load -w timeshot.plist
  6. Confirm its running with launchctl list | grep timeshot
<?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>timeshot</string>
<key>WorkingDirectory</key>
<string>/Users/jpillora/Pictures/Timeshots/</string>
<key>ProgramArguments</key>
<array>
<string>/bin/bash</string>
<string>timeshot.sh</string>
</array>
<key>KeepAlive</key>
<true/>
<key>StandardOutPath</key>
<string>timeshot.log</string>
<key> StandardErrorPath</key>
<string>timeshot.log</string>
</dict>
</plist>
#!/bin/bash
echo "[$(date +%Y\-%m\-%d\_%H.%M.%S)] timeshot starting in $(pwd)"
while [ 1 ]; do
#screenshot filename
d=$(date +%Y\-%m\-%d);
f=$(date +%H.%M.%S).jpg;
#capture as jpg
mkdir -p $d;
screencapture -t jpg -x "$d/$f";
#resize to maximum width of 2048
sips -Z 2048 $f > /dev/null 2>&1;
#wait 5mins
sleep 300;
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment