[clug] Real Time Clock Alarm Power Management Management

Hal Ashburner hal at ashburner.info
Sat Mar 31 16:58:02 MDT 2012

Hey Clug,

Yes management. Twice.

Once enabled in the bios, I can turn my computer on at specified times
using the following script

echo 0 > /sys/class/rtc/rtc0/wakealarm      #this clears the previous alarm
echo $1 > /sys/class/rtc/rtc0/wakealarm     #this writes the new alarm
where $1 is seconds since epoch

That's great and mythtv uses it to turn the machine on to record tv at the
appropriate time.

I'd quite like it to be a generalised service so other programs can use the
same feature without fighting for it. This way I could schedule the machine
come on in the morning on days when I know I'm going to want it, have the
machine come on and fire up a little quiet and relaxing Wagner l in an
ungainly attempt to get me out of bed when I really don't want to be. Other
people may have other uses and I might seriously look at some of this
automation stuff so that the pain of the valkyries or power chords is
somewhat alleviated by the a cup of coffee and/or some cracking toast. It's
also the sort of thing that lends itself well to those little gui things
that cling desperately to your taskbar. I'd like something similar on my
laptop at times too.

Now obviously I can sit down and write some code, should be fairly
Have some kind of database file. When any program wants to set a power on
alarm it contacts a daemon which then inserts the power on time into a
human readable database file.
On shutdown the daemon reads and updates the file, removes any expired
entries, picks the next wake and writes it to /sys/class/rtc/rtc0/wakealarm.
Maybe this is so lightweight that it can do the same thing at various other
times just in case system shutdown doesn't go according to the book.

Any scripting language from pure sh up to and including $your_language with
$your_favourite_killer_feature should work fine. I'd use C++ this week
because I'm enjoying C++ at the moment. No really it's true. I'm using
eclipse as my editor. I'm not sorry and I'm not ashamed either so put that
in your pipe!

I've failed to find something obvious that does this (written by someone
smarter than me - which goes without saying).

So do you know of something (and someone)? Do you see any horrid flaws in
my scheme? Some sort of callback mechanism to ensure that the program that
set the alarm starts running when the machine is turned on? Any thoughts on
whether it'd have any support? Enough support for someone to bother
packaging it?
Abstract the alarm mechanism so it can use the same interfaces but sets
alarms in ways relevant for different machines? (What machines? How do they
do it? Is it sufficiently popular to make us care?)
Anything else you want to tell me of which I can take insufficient heed at
my peril?


More information about the linux mailing list