@@ -0,0 +1,1953 @@
+# logic: detect idle time from mac os (mouse and keyboard) and force to go to a specific website%0A# to run the program, administrator needs to set the sleeptime, temp_idle_value and url%0A# Firefox should be the default browser, hide all other applications and docking on the screen%0A# set no screensaver%0A%0A# install fullscreen firefox add-ons (to maintain the full screen mode of your firefox browser): https://addons.mozilla.org/en-US/firefox/addon/resizeit/contribute/roadblock/?src=search&version=3.6.2%0A# put the file in desktop, then open terminal to go to Desktop directory, type: python %5Bfilename%5D %0A%0Aimport sys,os,time%0Aimport webbrowser%0A%0A# define variable%0Asleeptime = 10  #how frequent to get the idle time%0Atemp_idle_value = 60  #Duration to reset browser (in sec format)%0Aurl = %22http://www.facebook.com%22%0A%0Adef main_loop():%0A    while 1:%0A%0A%09%09time.sleep(sleeptime)%0A%09%09cmd = %22ioreg -c IOHIDSystem %7C perl -ane 'if (/Idle/) %7B$idle=(pop @F)/1000000000; print $idle%7D'%22%0A%09%09result = os.popen(cmd)  #use popen instead of os.system to open a perl script%0A%09%09str = result.read()%0A%09%09temp_idle = int(str.split(%22.%22)%5B0%5D)%0A%09%09#print(str)%0A%09%09%0A  %09%09if temp_idle %3E temp_idle_value and status == 0:%0A  %09%09%09resetBrowser()%0A  %09%09%09status = 1%0A  %09%09%09%0A  %09%09elif temp_idle %3E temp_idle_value and status == 1:%0A  %09%09%09print(%22do nothing%22)%0A  %09%09%09%0A  %09%09else:%0A  %09%09%09print(%22continue%22)%0A  %09%09%09status = 0%0A%0Adef resetBrowser():%0A%09result1 = os.system(%22ps axo pid,command %7C grep '%5Bf%5Direfox'%22)  #256 means not active, else will display a whole line%0A%09if result1 == 256:%0A%09%09print(%22firefox is inactive -%3E start a browser%22)%0A%09%09webbrowser.open_new(url)   #workable%0A%09else:%0A%09%09print(%22should kill the browser then open a firefox%22)%0A%09%09os.system(%22killall -9 firefox%22)%0A%09%09time.sleep(5)  %0A%09%09webbrowser.get(%22firefox%22)%0A%09%09webbrowser.open(url, new=0, autoraise=False)%0A%09%09%0A%0Aif __name__ == '__main__':%0A    %0A    try:%0A        status = 0%0A        main_loop()%0A    except KeyboardInterrupt:  #control+c in mac%0A   %09%09print ('stop')%0A    sys.exit(0)%0A%0A%0A%09%0A

Create checkinactivity.py