There is lockd.py in the net. I mean it's been a while since i got it from somewhere. It is a simple python that locks ur screen when you shut the proximity sensor and unlocks ur screen when you shake the phone. You can set time, for how long should the sensor be shut in order to lock the scree. P.s. don't forget to change format to .py