I'm sure you are all well aware of the problems with KO/PI alarms on pdaxrom. I checked all the relevant threads in this forum but couldn't find a working solution. So I started designing my own.
My solution doesn't scan ko/pi's data file for the next alarm, but uses the two files (/home/root/.kopi_next_alarm & .kopi_suspend_alarm) created by ko/pi and relies on ko/pi to play the alarmtone and display the alarm message. My proposed solution can therefor not be called an 'alarm applet' as it just tries to fire-up the zaurus shortly before an alarm event triggers and as it requires KO/PI to be running.
The first problem I had to solve was related to bad parameters KO/PI used to play the alarm sound with the playwave command. This was easy to solve, as I just removed the offending sampling rate option '-r ....' from the source and recompiled KO/PI. With this simple change KO/PI could play the alarm sound given my zaurus was already running when the alarm was triggered.
Next I wrote three little scripts that would wake up the zaurus just before an alarm, so that KO/PI could ring the alarm. As you might know, the zaurus runs all scripts found in the folder /etc/apm/wakeup.d just before suspending. Each script either returns nothing or the number of minutes the zaurus should wait before wakeing up. So I created two little shell scripts (/etc/apm/wakeup.d/next_kopi_alarm & /etc/apm/wakeup.d/next_kopi_suspend) that are simple wrappers to the real awk script /etc/apm/scripts.d/min_to_next_kopi_alarm.awk. These scripts just return the remaining minutes until the next alarm and are called just before the zaurus suspends.
So far so good. My Zaurus could now wake up just before an alarm and play the alarm sound. For some strange reason this only worked for alarms on the same day, and not for alarms e.g. the next morning. As can be easily seen in the suspending scripts, apmsleep is called in the following manner:
apmsleep +0:n
with n being the number of minutes until the next alarm (note: n can be bigger than 60). As it turned out, the Zaurus wouldn't wakeup if the next alarm wrapped around midnight. It turned out, that apmsleep is indeed not aware of day wraps and was thus waiting for a time that alread passed.
My first tests after making the apmsleep command aware of day wraps seem to work. I am, however, not sure that it works correctly with all timezones.
Attached you find the apmsleep.c with my suggested changes. If you feel like playing around with it you need the apmd_3.2.1.orig.tar.gz package from the pdaxrom site to compile. Otherwise just use the binary version I included in this thread.
I don't take any responsibility if it doesn't work or even fries your Z ;-)
any comments or suggestions?
regards, Philippe
### Installation
1. copy all the files (except apmsleep.c) to your zaurus (in my case a SL-C3100)
2. mv next_kopi_suspend next_kopi_alarm /etc/apm/wakeup.d
3. mv min_to_next_kopi_alarm.awk /etc/apm/scripts.d
4. mv /usr/bin/apmsleep /usr/bin/apmsleep.orig
5. mv apmsleep /usr/bin
6. check, that all files are executable