GPS
}
-public class Alarm : Object
-{
- public signal void trigger(Alarm a);
+/*
+TODO: schedule alarms via at
+
+Uses the 'z' queue.
+
+atq -q z can be used to list the jobs (for example, at startup, or after a job has run)
+at -c id can be used to query a job, parsing its contents (which can have
+ comments or variables being set)
+zavai --notify ... can be used to notify the job (and start zavai if it's not running)
- public time_t deadline;
- public string label;
+Alarm needs to be able to serialize itself to an at invocation and to
+deserialize itself from the output of at -c
- public Alarm(time_t deadline, string label)
+Alarm needs to deserialize also a job with no special markers whatsoever: a
+generic at job.
+
+
+
+refresh_alarms()
+{
+ oldtime = next_alarm ? next_alarm.time : 0
+ next_alarm = the first alarm from atq
+ if (oldtime != next_alarm.time)
{
- this.deadline = deadline;
- this.label = label;
+ remove existing triggers
+ (triggers can be skipped if we don't need to support non-zavai alarms)
+ schedule a trigger calling refresh_alarms() at next_alarm.time + 30 seconds
+ (triggers can be skipped if we don't need to support non-zavai alarms)
}
}
+at clock constructor: refresh_alarms()
+inotifywait -e close /usr/bin/at -> refresh_alarms() (shows when someone has just used at)
+ (can be skipped if we don't need to support non-zavai alarms)
+at alarm triggered through zavai: refresh_alarms()
+
+
+*/
+
+
+public class Alarm : Object
+{
+ // Notify of an alarm being triggered
+ //public static signal void trigger(string label);
+
+ // Schedule with at
+ public static void schedule(time_t deadline, string label);
+
+ // Get the label of the job with the given at ID
+ public static string getLabel(int atID);
+}
+
private int alarm_compare(void* a, void* b)
{
return (int)(((Alarm*)a)->deadline - ((Alarm*)b)->deadline);
// Set up zavai
+ int id = at.earliestID();
+ stderr.printf("%d\n", id);
+ bool res = at.jobContents(id, fd => {
+ FileStream fs = FileStream.fdopen(fd, "r");
+ if (fs == null)
+ return false;
+ string? line;
+ while ((line = fs.read_line()) != null)
+ stdout.printf(" LN %s\n", line);
+ });
+
+ return 0;
+
// Core infrastructure
zavai.config = new zavai.Config();
zavai.registry = new zavai.Registry();