RSS

WakeUp!

08 Apr

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?πŸ˜‰

 
2 Comments

Posted by on April 8, 2012 in Python

 

Tags: ,

2 responses to “WakeUp!

  1. jayrambhia

    April 9, 2012 at 4:41 am

    So, did you wake up or not ?

     

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

 
%d bloggers like this: