Python Script for an alarm
Today I wanted to get up at 6am to reach college, at time! Submissions, you see!😉
So wanted to keep alarm for that. But my phone’s alarm was not working. I would have told my parents to wake me up, but, they are out of town. Could have told my neighbour, but then waking them up at 2am just to ask them to wake you up at 6am doesn’t seem good, does it? (Agar bell maarta itni raat ko toh mujhe vaise hi maar dete vo😛 ) So tried to keep an alarm in my laptop using sudo apt-get install toshutils. But that feature was not available for my laptop. *sigh*
Asked 2 friends to wake me up. But then, couldn’t rely on them.😛 (Even they are humans! And friends ko bhool jaaneki bimaari hoti hai😛 )
Asked Jay what to do. He said “Python script likh daal for alarm for the laptop”😀
So I wrote this python script for alarm. You just need to give time, in 24 hour format, for when you want your alarm to ring, for eg: if you want alarm to ring at 6am, you type 0600
After doing that, go to sleep, peacefully!🙂
At 6am, banshee player will be played.
The python script that I wrote is
import os import time timer=raw_input("Alarm should ring at: ") hour=timer[:2] minute=timer[2:] def run(): t=time.ctime() currenttime_hour=t[11:13] currenttime_minute=t[14:16] if currenttime_hour==hour and currenttime_minute==minute: os.system('banshee --play &') time.sleep(4) os.system('banshee --play') else: time.sleep(60) run() def main(): run() if __name__== '__main__': main()
It took me a lot of time for testing this code because Banshee player does not play in a go. You have to give ‘banshee –play’ again for it to play. Realizing this part took almost an hour.😦
Nevertheless, we got to know something about banshee player!😀
Will put up the code at Github as I get time.
So, adios people, going to sleep now, have to get up at 6, remember?😉