Skip to content

Instantly share code, notes, and snippets.

@jcla1
Forked from jehiah/activity_snapshot.sh
Last active December 22, 2015 19:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jcla1/6522769 to your computer and use it in GitHub Desktop.
Save jcla1/6522769 to your computer and use it in GitHub Desktop.
#!/bin/sh
# computer activity data collection for http://jehiah.cz/one-two/
# initially by Jehiah Czebotar. Modified by Joseph Adams
FILE="data/misc/activity_log/`date +%Y%m%d`.log"
FRONT_APP="data/misc/cron/frontApp/frontApp.applescript"
function log_activity()
{
local UTC=`date "+%s,%Z"`
local IDLE=$((`/usr/sbin/ioreg -c IOHIDSystem | sed -e '/HIDIdleTime/!{ d' -e 't' -e '}' -e 's/.* = //g' -e 'q'` / 1000000000 ))
local ACTIVE_PROGRAM=$(/usr/bin/osascript $FRONT_APP)
echo "$UTC,$IDLE,$ACTIVE_PROGRAM" >> $FILE
}
log_activity
sleep 30
log_activity
tell application "System Events"
name of first application process whose frontmost is true
end tell
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment