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
  • Select an option

  • Save jcla1/6522769 to your computer and use it in GitHub Desktop.

Select an option

Save jcla1/6522769 to your computer and use it in GitHub Desktop.

Revisions

  1. jcla1 revised this gist Sep 14, 2013. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion activity_snapshot.sh
    Original file line number Diff line number Diff line change
    @@ -3,7 +3,7 @@
    # initially by Jehiah Czebotar. Modified by Joseph Adams

    FILE="data/misc/activity_log/`date +%Y%m%d`.log"
    FRONT_APP="data/misc/cron/activity_snapshot/frontApp.applescript"
    FRONT_APP="data/misc/cron/frontApp/frontApp.applescript"

    function log_activity()
    {
  2. jcla1 revised this gist Sep 14, 2013. 1 changed file with 3 additions and 2 deletions.
    5 changes: 3 additions & 2 deletions activity_snapshot.sh
    Original file line number Diff line number Diff line change
    @@ -1,14 +1,15 @@
    #!/bin/sh
    # computer activity data collection for http://jehiah.cz/one-two/
    # by Jehiah Czebotar
    # initially by Jehiah Czebotar. Modified by Joseph Adams

    FILE="data/misc/activity_log/`date +%Y%m%d`.log"
    FRONT_APP="data/misc/cron/activity_snapshot/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 frontApp.applescript)
    local ACTIVE_PROGRAM=$(/usr/bin/osascript $FRONT_APP)

    echo "$UTC,$IDLE,$ACTIVE_PROGRAM" >> $FILE
    }
  3. jcla1 revised this gist Sep 14, 2013. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion frontApp.applescript
    Original file line number Diff line number Diff line change
    @@ -1,3 +1,3 @@
    tell application "System Events"
    set frontApp to name of first application process whose frontmost is true
    name of first application process whose frontmost is true
    end tell
  4. jcla1 revised this gist Sep 13, 2013. 2 changed files with 5 additions and 2 deletions.
    4 changes: 2 additions & 2 deletions activity_snapshot.sh
    Original file line number Diff line number Diff line change
    @@ -2,13 +2,13 @@
    # computer activity data collection for http://jehiah.cz/one-two/
    # by Jehiah Czebotar

    FILE="../activity_log/`date +%Y%m%d`.log"
    FILE="data/misc/activity_log/`date +%Y%m%d`.log"

    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 -e 'tell application "System Events"' -e 'set frontApp to name of first application process whose frontmost is true' -e 'end tell')
    local ACTIVE_PROGRAM=$(/usr/bin/osascript frontApp.applescript)

    echo "$UTC,$IDLE,$ACTIVE_PROGRAM" >> $FILE
    }
    3 changes: 3 additions & 0 deletions frontApp.applescript
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,3 @@
    tell application "System Events"
    set frontApp to name of first application process whose frontmost is true
    end tell
  5. jcla1 revised this gist Sep 11, 2013. 1 changed file with 0 additions and 0 deletions.
    Empty file modified activity_snapshot.sh
    100644 → 100755
    Empty file.
  6. jcla1 revised this gist Sep 11, 2013. 1 changed file with 2 additions and 2 deletions.
    4 changes: 2 additions & 2 deletions activity_snapshot.sh
    Original file line number Diff line number Diff line change
    @@ -2,7 +2,7 @@
    # computer activity data collection for http://jehiah.cz/one-two/
    # by Jehiah Czebotar

    FILE="activity_log/`date +%Y%m%d`.log"
    FILE="../activity_log/`date +%Y%m%d`.log"

    function log_activity()
    {
    @@ -15,4 +15,4 @@ function log_activity()

    log_activity
    sleep 30
    log_activity
    log_activity
  7. @jehiah jehiah created this gist Jan 7, 2013.
    18 changes: 18 additions & 0 deletions activity_snapshot.sh
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,18 @@
    #!/bin/sh
    # computer activity data collection for http://jehiah.cz/one-two/
    # by Jehiah Czebotar

    FILE="activity_log/`date +%Y%m%d`.log"

    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 -e 'tell application "System Events"' -e 'set frontApp to name of first application process whose frontmost is true' -e 'end tell')

    echo "$UTC,$IDLE,$ACTIVE_PROGRAM" >> $FILE
    }

    log_activity
    sleep 30
    log_activity