I tried many techniques to do exactly what you asked, but failed to do something satisfactory. Went with sleep due to time constraints.