Skip to content

Instantly share code, notes, and snippets.

@chaoxu
Created March 5, 2011 07:07
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 chaoxu/856198 to your computer and use it in GitHub Desktop.
Save chaoxu/856198 to your computer and use it in GitHub Desktop.
count amount of key strokes
#!/usr/bin/python
import sys
import atexit
import time
global count
global fname
fname = '/home/mgccl/.keycount'
def savecounter():
f = open(fname,'w')
f.write(str(count))
f.write('\n')
f.close()
atexit.register(savecounter)
f = open(fname,'r')
count = int(f.readline())
f.close()
t = time.time()
input = open("/dev/input/event"+sys.argv[1],'rb')
while True:
input.read(96)
count+=1
#print(count)
if (time.time() - t > 60):
t = time.time()
savecounter()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment