Skip to content

Instantly share code, notes, and snippets.

View rypit's full-sized avatar

RJ Pittman rypit

View GitHub Profile
@rypit
rypit / activity_snapshot.sh
Last active December 11, 2015 17:58 — forked from lucaspiller/activity_snapshot.sh
Modified to export a JSON formatted object per entry.
#!/bin/sh
# computer activity data collection for http://jehiah.cz/one-two/
# Originally by Jehiah Czebotar. This verison by Luca Spiller, then RJ Pittman.
FILE="$HOME/Dropbox/activity_log/`hostname`-`date +%Y%m%d`.log"
function log_activity()
{
local TIME=`date "+%Y-%m-%dT%H:%M:%S%z"`
local IDLE=$((`/usr/sbin/ioreg -c IOHIDSystem | sed -e '/HIDIdleTime/!{ d' -e 't' -e '}' -e 's/.* = //g' -e 'q'` / 1000000000 ))
#!/bin/sh
IDLE=$((`/usr/sbin/ioreg -c IOHIDSystem | sed -e '/HIDIdleTime/!{ d' -e 't' -e '}' -e 's/.* = //g' -e 'q'` / 1000000000 ))
FILE="$HOME/Dropbox/daily_photo/`date +%Y%m%d`.png"
if [ $IDLE -lt 61 ]; then
PID=`ps auxww |grep loginwindow | grep -v grep | awk '{print $2}'`
D=`date +%Y%m%d_%H%M%S`
imagesnap $FILE
fi