This is an interesting idea, I hate to forgetting turning wifi off before going to bed and find my phone dead in the morning. Installed script and it works fairly good for 3G. Seems like wlan keeps sending packets although the device is idle. A more accurate way to turn connections off would be to check for user inactivity but I have no idea how to check that via a shell script.