Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot
 
PerlMonks  

Alarm clock

by Anonymous Monk
on Dec 30, 1999 at 05:26 UTC ( #1544=CUFP: print w/ replies, xml ) Need Help??

I seem to be resistant to traditional alarm clocks, yet still find myself needing to get up early. I have a perl one-liner in my crontab that uses X10 to turn on the lights in my room, and it starts up XMMS playing loud music. THAT always gets me up in the morning.

Comment on Alarm clock
RE: Alarm clock
by vroom (Pope) on Dec 30, 1999 at 05:33 UTC
    I've got just the opposite, I let my mp3s play when I go to bed and then have a script Perl script kill the process in a half an hour or an hour.
RE: Alarm clock
by Anonymous Monk on Jan 07, 2000 at 20:20 UTC
    Source code, man! What good is it to talk about cool uses for Perl if you don't give code?
      Source code? Once, when away on a trip I was horrified to find that a) I'd left my alarm clock at home and b) the one in my room looked, well, really ill. So wrote a snippet which fired up the CD in the laptop. It was a simple loop which calculated the time-delta, slept for half of it and fired up the CD if the delta was less than 1 minute. Leave the volume up and something suitabley LOUD in the disk.
        That was me - I was particularily paranoid about seeing a heart beat. The current version calculates the delay, reformats it as hours and minutes(for idiot proofing) and pops up a TK/TCL window to grab my attention (in case the volume is down)


        Butlerian Jihad now!
RE: Alarm clock
by Xavier (Novice) on Feb 24, 2000 at 11:50 UTC
    I have something similar setup, albeit a mite more complex. I, too, have X-10 setup but I also got a freebie motion detector. I figured I might as well put it to some use, so I decided to make an alarm clock (no, more alarm SYSTEM) that used it. The way it is configured now, I have the motion detector near my computer where it cannot see the bed (very well (I need to block its range a bit more)). the alarm system is just a big ol'e perl script that gets activated by a cron job and turns on a bunch of noisy/bright x-10 devices. the catch is that it checks the motion detector until it actually detects movment (as in I actually got up). the system also, just to top things off, checks a list of holidays to see if it should actually bother waking me up and best yet: checks for school closings (snow days). now all i need to do is have it tilt up my bed, drop me through the floor and into some nice, mechanical trousers. oh, wait, that's already been done ;-)
      Any source code for that? It sounds great. I'm a bit far off but have this so far works fine, although incomplete....

      #!/usr/bin/perl $servertime = localtime (time); $x = 0; $Day = "Wed"; $Month = "Dec"; $Date = "5"; $Time = "10:15:30"; $Year = "2007"; $AudioFileName = "04 - Dido - Marys In India - EMG - www.elitemusic.e +s.vg.mp3"; $Player = "xmms"; print ("\r\n \r\n \r\n"); print ("-------------------------------------------------------------- +--------------- \r\n"); print ("Welcome To Dans Perl Alarm Clock For Linux\r\n"); print ("Created by Dan Gibas - http://www.hygen.net\r\n"); print ("-------------------------------------------------------------- +--------------- \r\n"); print ("\r\n \r\n \r\n"); print ("Hit ENTER to continue setup...\r\n"); $Begin = <STDIN>; print ("\r\n \r\n \r\n"); print ("Enter Alarm Day:\r\n\r\n"); print ("(Choose a number from 1 to 7)\r\n"); print ("1 = Mon\r\n"); print ("2 = Tue\r\n"); print ("3 = Wed\r\n"); print ("4 = Thu\r\n"); print ("5 = Fri\r\n"); print ("6 = Sat\r\n"); print ("7 = Sun\r\n"); $Day = <STDIN>; print ("Enter Alarm Month:\r\n\r\n"); print ("(Choose a number from 1 to 12)\r\n"); print ("1 = Jan\r\n"); print ("2 = Feb\r\n"); print ("3 = Mar\r\n"); print ("4 = Apr\r\n"); print ("5 = May\r\n"); print ("6 = Jun\r\n"); print ("7 = Jul\r\n"); print ("8 = Aug\r\n"); print ("9 = Sep\r\n"); print ("10 = Oct\r\n"); print ("11 = Nov\r\n"); print ("12 = Dec\r\n"); $Month = <STDIN>; if ($Day == 1){ $Day = "Mon"; } if ($Day == 2){ $Day = "Tue"; } if ($Day == 3){ $Day = "Wed"; } if ($Day == 4){ $Day = "Thu"; } if ($Day == 5){ $Day = "Fri"; } if ($Day == 6){ $Day = "Sat"; } if ($Day == 7){ $Day = "Sun"; } if ($Month == 1){ $Month = "Jan"; } if ($Month == 2){ $Month = "Feb"; } if ($Month == 3){ $Month = "Mar"; } if ($Month == 4){ $Month = "Apr"; } if ($Month == 5){ $Month = "May"; } if ($Month == 6){ $Month = "Jun"; } if ($Month == 7){ $Month = "Jul"; } if ($Month == 8){ $Month = "Aug"; } if ($Month == 9){ $Month = "Sep"; } if ($Month == 10){ $Month = "Oct"; } if ($Month == 11){ $Month = "Nov"; } if ($Month == 12){ $Month = "Dec"; } print ("\r\n \r\n \r\n"); print ("-------------------------------------------------------------- +--------------- \r\n"); print ("Alarm activated! \r\n"); print ("Alarm will go off at: $Day $Month $Date $Time $Year \r\n"); print ("Alarm will play: $AudioFileName \r\n"); print ("[^c to quit] \r\n"); print ("-------------------------------------------------------------- +--------------- \r\n"); while ($x < 10) { $servertime = localtime (time); if ($servertime eq "$Day $Month $Date $Time $Year"){ $x = 100; exec ("$Player \"$AudioFileName\""); } }

      It uses a bit too much CPU but works...

      more info here - http://www.hygen.net/blog/

      Edit: g0n - code tags

        Is it Perl language code? I don't beleive!
Re: Alarm clock
by Anonymous Monk on May 04, 2009 at 15:29 UTC
    where is the code?

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: CUFP [id://1544]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others studying the Monastery: (5)
As of 2014-09-02 02:20 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My favorite cookbook is:










    Results (18 votes), past polls