Wake Up with Bash

Like so many, I have problems sleeping… and waking up. While I’m not sure what to do about making myself fall asleep faster (the mind just won’t turn off), I am now using this method of waking myself up. It has worked wonderfully for the past week. I have had about 6 hours of sleep each night, and wake up completely refreshed and ready to go. Before this, I would get 7-8, and sometimes 9 hours of sleep, and would wake up dead tired and completely unmotivated; all I wanted to do was check for urgent mail, and fall back into bed. Needless to say, I’m loving the extra few hours in the morning. Maybe I’ll eventually become a “morning person.” (I like the theory of early morning wake up, but I generally hate it in practice :-)).

My method for the “quiet” alarm was to schedule my wake up in Evolution, and have the appointment alarm execute “banshee –play”. I would have a Banshee instance running, paused on a quiet song that would slowly increase volume. Subsequent songs in the wake up playlist would be fairly mellow. The idea is to have the first song fade in, so there’s no abrupt noise to jolt you awake. The fall back alarm is your typical buzzing alarm clock we all despise.

The Evolution approach has actually been fairly annoying. I don’t always like to wake up at exactly the same time, so having recurring wake up appointments just leaves me having to edit the appointment each night. So tonight I wrote a simple timeout shell script that takes a string that is passed to the date program to calculate a timeout.

$ ./wakeup.sh 8am && banshee --play
Terminating on Tue Nov 1 08:00:00 EST 2005
Expires in: 06:12:19

That’s pretty simple. It will then show the full date/time string, so you can verify date properly parsed your wake up time string, and then it will count down the number of hours, minutes, and seconds before “expiring.” This is nice because it gives you an idea of exactly how much sleep you may get (provided you can fall asleep shortly thereafter). When it expires, it will either exec the second argument, or just quit if no second argument was specified, so you can use it just like sleep.

For those interested, the script is here. Happy waking up!

Oh, and Banshee 0.9.9 was released.

5 Replies to “Wake Up with Bash”

  1. I used to use `at` to set my alarm, something along the lines of:

    $ at -f somescript 6:00 tomorrow

    The -f option just specifies what script to run at the specified time, I used to have it run mpg123 on some punk rock with the volume cranked up.

    The ‘at’ command is pretty nice becuase it understands a wide range of date/time formats, eg “now + 6h” to run 6 hours from now. Spiffy.

  2. at is a very nice little utility, but for some reason I really wanted my timer to tick. It tells you how long before it goes off, which is really nice because if you don’t actually close the laptop lid, or turn away from the computer, etc, before you go to bed, the ticking pressures you into it because you are more aware that you are losing valuable sleep time.

  3. Ah, comments work now!

    I tried to comment back at the time, in relation to the linked alarm clock article, about a potentially useful option for Banshee..

    How about:
    $ banshee –play [–fade-duration 900 [–fade-from 15] [–fade-to 100(% volume)]]

    I’m sure there was an xmms plugin that did something along those lines (probably with more advanced alarm-like functions), but then it’s no longer my preferred music-playing application.. :)

  4. For sleep, go and get yourself a bottle of melatonin 3mg (decent supermarket in the herbal section or a nat/health food store, make sure you get 3 mg (milligrams) not 0.3 (300 micrograms)). Take one 30 min before you want to go to sleep. Works great, no after effects can be used indefinitely.

    melatonin is used in the body to create tryptophan (the same stuff in turkey/poultry that makes you drowsy). Taking melatonin kicks off the body’s natural sleep cycle, and you’ll fall asleep and stay out for 8 hrs and wakeup refreshed. (don’t try and go back to sleep as if you do you’ll wakeup groggy)

Comments are closed.