Finding calendar software that I like. AKA, writing it.

Tam and I crossed the line sometime this spring where we could no longer keep all of our commitments in our heads. Equally likely for this is the increasing scope and complexity of our commitments, or our decreasing mental facilities.

First off, we decided to use remind. It seems to have the most descriptive frontend for making entries, and many flexible backends for displaying calendars as postscript, html, or even vcard. We created a different calender file for different categories, and a top level calendar that includes them all.

Since remind uses flat text files, we decided to use monotone. This allows us to do all of the usual good version control stuff (ancestry, logs, branching and merging), as well has having a distributed repository (useful for moving files around).

A simple script, run from cron, maintains an online, HTML version of the calendar:

#!/bin/sh

PATH=/bin:/usr/bin:/opt/bin
IN=....
OUT=....

cd $IN && monotone update

year=$(date +%Y)
for i in $(seq 12)
do
	month=$(date +%B --date=$i/01/$year)
	remind -p calendar $month 1 $year | rem2html  > $OUT/${i}.html
done

I have a cell phone that has a calendar application, and a bluetooth interface, so I thought I'd give having the calendars on my phone a swing.

This turns out to be easy possible using gammu. Gammu can interpret and load vcs (I'm sure there's actually a standard for that) onto my Sony Ericsson z600 over bluetooth. This requires getting bluetooth running under linux, and getting gammu working over bluetooth.

Bluetooth has been around a while now, so there is a fair amount of documentation on how to get it working. It basically boils down to:

Once you've established that the phone and the linux box can talk (using l2ping), then setting up gammu is pretty easy. Here is my gammurc:

[gammu]
port = BT ADDRESS
connection = blueat
logformat = textall
startinfo = yes

You can test out if gammu is working by simply doing a gammu --identify. After doing a bit of reverse engineering, and some digging around on the web about how to load calendars onto phones using gammu, I patched together a script to create the vcs files from remind.

#!/bin/bash
# XXX: any event without a duration gets assigned a duration of 60 minutes
# XXX: any all-day event gets assigned a start time of midnight and a duration
# of 23:59
# XXX: this most certainly does not deal with events that wrap over day
# boundaries correctly. 

CAL=./calendar
WEEKS=2

remind -s+${WEEKS} -b2 ${CAL} | \
    (	echo BEGIN:VCALENDAR
	echo VERSION:1.0
 
	while read date x y duration start msg 
	do 
	    [ $start = '*' ] && { start=0000 ; duration=1439 ; } 
	    [ $duration = '*' ] && duration=60
	    date=${date//\//}

	    sh=$(printf %.2d $((start/60)))
	    sm=$(printf %.2d $((start%60)))
	    eh=$(printf %.2d $(( (start+duration) / 60 )))
	    em=$(printf %.2d $(( (start+duration) % 60 )))
			# the printfs are needed for zero padding

	    echo
	    echo BEGIN:VEVENT
	    echo CATEGORIES:MEETING
	    echo SUMMARY:$msg
	    echo DTSTART:${date}T${sh}${sm}00
	    echo DTEND:${date}T${eh}${em}00
	    echo END:VEVENT
	    echo 

	done 
	echo END:VCALENDAR
    )

Since bluetooth has suprising range, I also wrote a script to be run from cron that will backup the phone, and then load the calendars onto the phone once a day. I usually have my phone somewhere around me, and I'm usually sleeping or at least at home at 0400h, so that's when the cron jobs run.

#!/bin/sh

PATH=/opt/bin
IN=...
date=$(date +%y%m%d)
BACKUP=/usr/home/jack/var/phone/z600.backup.${date}

tmp=/usr/home/jack/tmp/sync.${$}.vcs
	# gammu uses filename extensions to recognize files. 

gammu --backup $BACKUP -yes

cd $IN && monotone sync && monotone update

./scripts/make_vcs.sh > $tmp
echo ALL | gammu --restore  $tmp
rm $tmp

Only 2 weeks of calendar are loaded onto the phone, mainly to make for reasonable transfer times.

There are still a few things left to do. Having the phone issue reminders would be cool. As would having email reminders.


jack | posted Wed Jul 20 11:56:50 2005 | #
category: projects/calendar

A weblog by Jack Cummings