From 8a3d2c99bff60cb775ebc42516c0c3912d54ba3d Mon Sep 17 00:00:00 2001 From: Calvin Morrison Date: Sat, 22 Aug 2026 13:16:49 -0400 Subject: 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// 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 --- pim/rc/who | 87 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 87 insertions(+) create mode 100755 pim/rc/who (limited to 'pim/rc/who') diff --git a/pim/rc/who b/pim/rc/who new file mode 100755 index 0000000..353ca4f --- /dev/null +++ b/pim/rc/who @@ -0,0 +1,87 @@ +#!/bin/rc +# pim/who -- who you met with, over a range of days. +# +# pim/who the last seven days +# pim/who -n 30 the last thirty +# pim/who -a only those who accepted +# pim/who -x calvinm leave yourself out +rfork e + +mtpt=/mnt/pim +days=7 +only=() +me=() +acc=() + +while(~ $1 -*){ + switch($1){ + case -m + mtpt=$2; shift + case -n + days=$2; shift + case -x + me=$2; shift + case -a + acc=1 + case -c + only=($only $2); shift + case * + echo 'usage: who [-m mtpt] [-n days] [-x me] [-a]' >[1=2] + exit usage + } + shift +} + +now=`{date -n} +from=`{date -i `{echo $now - $days '*' 86400 | bc}} +to=`{date -i `{echo $now + 86400 | bc}} + +cals=$only +if(~ $#cals 0) + cals=`{pim/calendars -m $mtpt} + +# Who counts as you comes from the calendar's me= in the config, which +# the server reports in ctl. -x adds to it. +ex=/tmp/who.ex.$pid +fn sigexit { rm -f $ex $tmp } +>$ex +if(! ~ $#me 0) + echo $me >>$ex +for(c in $cals) + sed -n 's/^cal .* me //p' $mtpt/calendars/$c/ctl >[2]/dev/null | + tr , ' ' | tr ' ' ' +' >>$ex +grep -v '^$' $ex >$ex^.t; mv $ex^.t $ex + +hits=() +for(c in $cals){ + echo 'from='^$"from^' to='^$"to >$mtpt/calendars/$c/query + for(r in `{cat $mtpt/calendars/$c/query}) + hits=($hits $mtpt/calendars/$c/$r) +} +if(~ $#hits 0){ + echo 'nobody, in the last '^$"days^' days' + exit 0 +} + +fn people { + for(h in $hits){ + d=`{basename -d $h} + ev=`{sed -n 's/^event: //p' $h} + if(! ~ $#ev 0){ + f=$d/$"ev/attendees + if(test -f $f){ + if(~ $#acc 0) + awk -F'\t' 'NF>2{print $3}' $f + if(! ~ $#acc 0) + awk -F'\t' 'NF>2 && $1 ~ /ACCEPTED/{print $3}' $f + } + } + } +} + +if(test -s $ex) + people | grep -v -f $ex | sort | uniq -c | sort -nr +if(! test -s $ex) + people | sort | uniq -c | sort -nr +exit 0 -- cgit v1.2.3