From Wed 20th December 2017 all the media from the HPR feeds will be served via a redirect towards Archive.org. Please notify admin@HPR of any issues.
An overview of a terrible, hacky method of waking up.
Hosted by Windigo on 2015-08-19 is flagged as Clean and is released under a CC-BY-SA license.
Listen in ogg,
mp3 format. | Comments (4)
This is an open series in which Hacker Public Radio Listeners can share their Bash scripting knowledge and experience with the community. General programming topics and Bash commands are explored along with some tutorials for the complete novice.
This is a quick summary of my alarm clock system, written in bash and highly
My preferred hardware platform is a Dell Mini 9.
My alarm clock is an embarrassing combination of bash scripts and Audacious, my
favorite media player. Any media player will do, as long as it's scriptable.
How It Works
There are currently two bash scripts in my crappy alarm setup. One script is
called "wakeup" and the other is called "wakeup-at".
wakeup is simply a wrapper that adds some error handling around audacious. It
launches audacious if it can't find an instance running already, waits five
seconds for it to get itself together, and then causes it to play. It is also
currently broken, so the 'launching audacious' part doesn't work. I have to
manually start audacious myself. FAILURE.
audacious -p &
You've noticed that the "wakeup" script doesn't actually have any timing
involved; If you want to use it as an alarm, you get to combine it with the bash
"sleep" command. This is not a failure, this is by design! An example alarm:
sleep 8h; wakeup
One problem with this methodology is that it requires math, and is prone to
errors. If I'm going to sleep at 10:46:33 PM and need to wake up at 7:00 AM, I
need to chain sleep commands together for each unit of time:
sleep 7h; sleep 14m; sleep 27s; wakeup
Get some of that math wrong, and you wake up at the wrong time. FAILURE.
"wakeup-at" is a wrapper around "wakeup" that uses the "at" utility to schedule
the wakeup script. So, instead of using multiple sleep commands, it accepts any
of the time formats that at accepts:
wakeup-at 7:00 AM
wakeup-at 6:00AM 2018-02-02
Here is the wakeup-at script:
## Make sure we have enough arguments
if [ $# -lt 1 ]
echo "Usage: `basename $0` <time>"
## Add custom time keywords
case "$1" in
echo wakeup | at 3:33 AM
## Catch-all; send all arguments to at
echo wakeup | at $@
If you make a syntax error, "at" tells you about it immediately. Its only
failings are what it inherits from the original "wakeup" script.
Subscribe to the comments RSS feed.
Comment #1 posted on 2015-08-19T10:28:33Z by Jon Kulp
The Very Essence
Windigo, I salute you. In this episode you have captured the spirit, The Very Essence of HPR. Either that or you were just trying to see if you could make Dave Morriss twitch enough to send shockwaves across the ocean and feel them over here. All of us listening I'm sure were shouting suggestions at our audio players but every last one of them would have drained the Awesome out of your alarm system. I see no bugs here...
Comment #2 posted on 2015-08-19T16:20:57Z by Dave Morriss
I wouldn't have done it that way...
A fine, entertaining show, Sir!
I didn't twitch excessively. I wasn't wild about the multiple 'sleep' solution, but then neither were you.
I thought the use of 'at' was great.
Back around 2005 I wrote a thing for my work (as a Sysadmin at a university) that allowed people to request migration of their mailboxes from a Unix mail system to Exchange by sending an email to a particular server. It slurped their mail out of one system and into the other using IMAP, but I didn't want there to be more than about 4 'slurp' jobs running at once because IMAP is not efficient.
Anyway, long story short, I used 'at' to schedule the work and to avoid bottlenecks. Supreme lash-up but it worked :-)
Yours was a perfect hacker story. Thanks!
Comment #3 posted on 2015-08-20T15:46:17Z by NYbill
I think the next logical step here is to enter the desired wakeup time into the Mini9 via clockwork.
Comment #4 posted on 2015-08-20T21:32:29Z by Beeza
Geekdom At Its Very Best
This episode shows precisely why non-geeks think that geeks are weird, while giving us geeks a nice warm glow.
Yes, you could buy an alarm clock for pennies, but where would the fun and sense of achievement be in that?
I once found myself in a hotel room without my phone or any other kind of alarm. I HAD to be up early to make an important meeting. My solution was to create a simple MS Access application (it was a company laptop) to poll the system clock until it reached 0530, then just repeatedly trigger the "beep". It took all of 5 minutes to code and test.
Note to Verbose Commenters
If you can't fit everything you want to say in the comment below then you really should record a response show instead.
Note to Spammers
All comments are moderated. All links are checked by humans. We strip out all html. Feel free to record a show about yourself, or your industry, or any other topic we may find interesting. We also check shows for spam :).