diff options
| author | Calvin Morrison <calvin@pobox.com> | 2026-08-22 13:16:49 -0400 |
|---|---|---|
| committer | Calvin Morrison <calvin@pobox.com> | 2026-08-22 13:16:49 -0400 |
| commit | 8a3d2c99bff60cb775ebc42516c0c3912d54ba3d (patch) | |
| tree | fd136a3b7927146763cdc11e6be07c71f92bb92c /pim/rc/agenda | |
| parent | 9aacce8b3b54060d0037eca897856d7273e6e5e8 (diff) | |
pim: personal information management, starting with a calendar
A calendar as a file tree, and tools that only know the tree:
events/date/yyyy/mm/dd/hhmm-summary as lived
events/uuid/<uid>/ as stored
ctl query alarm changed
lib/cal owns all of that. A backend supplies events and, where its
protocol allows, takes changes back -- six methods. cmd/icalfs is the
first: it reads .ics files from a directory and nothing else, because
fetching is rc/fetch's job and hget already exists. That keeps
net/http out of the binary and makes a subscribed calendar and a local
one the same thing.
The tools are rc on purpose. If the tree needs a compiled program to be
useful, the tree is the wrong shape. Three things were added to the
tree because the rc port needed them: a path from an occurrence to its
event, epoch seconds beside RFC3339, and a numeric slot for all-day
events so test(1) can compare it.
ctl reports caps, so a tool can say "read only" instead of trying and
failing. A published .ics is read only: nowhere to PUT, and no
METHOD:REQUEST to reply to. CalDAV would be read write rsvp schedule,
and that is the next backend.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Diffstat (limited to 'pim/rc/agenda')
| -rwxr-xr-x | pim/rc/agenda | 88 |
1 files changed, 88 insertions, 0 deletions
diff --git a/pim/rc/agenda b/pim/rc/agenda new file mode 100755 index 0000000..ec38ad2 --- /dev/null +++ b/pim/rc/agenda @@ -0,0 +1,88 @@ +#!/bin/rc +# pim/agenda -- what is happening, across every mounted calendar. +rfork e + +mtpt=/mnt/pim +days=7 +off=0 +only=() + +while(~ $1 -*){ + switch($1){ + case -m + mtpt=$2; shift + case -n + days=$2; shift + case -o + off=$2; shift + case -c + only=($only $2); shift + case * + echo 'usage: agenda [-m mtpt] [-n days] [-o dayoffset] [-c cal]' >[1=2] + exit usage + } + shift +} + +cals=$only +if(~ $#cals 0) + cals=`{pim/calendars -m $mtpt} +if(~ $#cals 0){ + echo 'pim/agenda: no calendars under '^$mtpt^'/calendars' >[1=2] + exit nocal +} +# only worth naming the calendar when more than one is in play +tag=0 +if(! ~ $#cals 1) + tag=1 + +tmp=/tmp/agenda.$pid +fn sigexit { rm -f $tmp } + +now=`{date -n} +i=$off +last=`{echo $off + $days | bc} +n=0 + +while(test $i -lt $last){ + sec=`{echo $now + $i '*' 86400 | bc} + day=`{date -f YYYY/MM/DD $sec} + + # name, calendar, summary, location -- one line per occurrence, + # keyed by the file name so a sort interleaves the calendars by time + { + for(c in $cals){ + d=$mtpt/calendars/$c/events/date/$day + if(test -d $d) + for(f in $d/*){ + b=`{basename $f} + sum=`{sed -n 's/^summary: //p' $f} + loc=`{sed -n 's/^location: //p' $f} + echo $"b^' '^$"c^' '^$"sum^' '^$"loc + } + } + } | sort >$tmp + + if(test -s $tmp){ + if(test $n -gt 0) + echo + n=1 + date -f 'WWW DD MMM YYYY' $sec + awk -F' ' -v 'tag='^$tag '{ + if ($1 ~ /^0000-allday-/) + t = "all day" + else + t = substr($1,1,2) ":" substr($1,3,2) + s = "\t" t "\t" $3 + if ($4 != "") + s = s " (" $4 ")" + if (tag) + s = s "\t" $2 + print s + }' $tmp + } + i=`{echo $i + 1 | bc} +} +if(~ $n 0) + echo 'nothing in the next '^$days^' days' +exit 0 |
