___________________________________________
title: Calendar Syncing with palm-calendar-sync2
date: 2024-10-11
 ___________________________________________

Attempts at Syncing a Calendar
 ===========================================

My first attempt at setting up my Calendar on the Zire was simple
enough, as both J-Pilot and the Zire itself make it easy to add
entries to the Datebook. I wanted more though, such as syncing my
Personal and Work calendar from Fastmail, which would contain full
daily schedules and allow me to use the Zire and potentially
replace my iPhone as my goto calendar.

My next attempt was trying to use older Linux distros to sync my
calendar with Evolution or another application that spoke CalDAV,
and then use a PIM conduit to sync to the Zire. As I discussed in a
previous post though, using an older Linux distro on a VM had it's
own set of problems.

While doing research into other ways of syncing a Calendar to
the Datebook, I came up with a general idea of how I could
accomplish it.

1. Use a cli tool that understood CalDAV or export to ics file
2. Import the .ics file and sync to the Zire
3. Setup some sort of script/automation to do this to use on a
daily basis

I came across a few tools that could these, but none really hit the
sweet spot of features and ease-of-use Finally I came across a tool
called palm-calendar-sync2 that could do everything and is actively
maintained which was promising since it didn't require an older 
distro or
dependencies.
palm-calendar-sync2
Building palm-calendar-sync2
 ===========================================

Setting up palm-calendar-sync2 is relatively easy, as it ships with
an Apptainer image (sort of like a Docker image for an app) that is
self-contained and doesn't require dependency hunting.
apptainer
While this did make things easier, I wanted to also build from
source in case I wanted to make any code updates (foreshadowing).

Building palm-calendar-sync2 unfortunately was not as
straightforward as I was expecting, as it requires pilot-link 
libraries and includes which are not present in the Debian packages
that J-Pilot ships with. It also requires a newer version of
libconfig that Debian 12 does not ship with, and both of these must
also be built from source.
pilot-link repo
libconfig
It took a few hours to get everything right, but here's the steps
to build palm-calendar-sync2 from source on a Debian 12 system.

```
 #Install Dependencies on Debian 12
 sudo apt-get install build-essential git \
  libcurl4-openssl-dev libical-dev libusb-dev autoconf \
  libtool libtool-bin libpopt-dev bison flex autotools-dev \
  automake

 #Remove conflicting libconfig-dev package
 sudo apt-get remove libconfig-dev

 #Build pilot-link
 git clone https://github.com/desrod/pilot-link.git
 cd pilot-link
 #Patch configure.ac from
 #https://aur.archlinux.org/cgit/aur.git/plain/configure-checks.pat
 ./autogen.sh
 make && sudo make install

 #Build libconfig
 git clone https://github.com/hyperrealm/libconfig.git
 cd libconfig
 autoreconf
 make && sudo make install

 #Reload library path and continue building palm-calendar-sync2
 sudo ldconfig
```

Copy the resulting sync-calendar2 binary into your local path.

Using palm-calendar-sync2
 ===========================================

Running sync-calendar2 is relatively straight forward, 
using the datebook.cfg config. I added my Fastmail "secret" URLs
for my calendars, updated the timezone to America/Los_Angeles
and set FROMYEAR=2024 to avoid adding older appointments to the
datebook.

Running sync-calendar2 in the same directory as this datebook.cfg w
prompt to wait for the Palm hotsync to start, and once kicked off
will sync the from CalDAV to the datebook

It works extremely well, and does what it says it will do, however
there are a few issues.

Issues with palm-calendar-sync2
 ===========================================

As I eagerly looked over my calendar on the Zire after it's first
sync, I noticed a few strange things,

 - Appointments were 7 hours ahead of their scheduled time
 - "phantom" appointments for events long removed
 - Recurring daily events were for the entire week
 - Calendar size was large on the Zire
 - Installing apps no longer worked
 - J-Pilot no longer worked

The last issue took me a day to figure out, and I wrote about it
more in a post dedicated to breaking hotsync.
I broke Hotsync
For the other issues, I played around with some timezone settings,
but nothing worked. Finally after convinced it must be a bug, I
opened an issue on Github,
Events In Incorrect Timezone
While there, I also opened a issue for some quality-of-life
suggestions like limiting the number of days to sync (instead of
just by year) and having an option to not sync Notes, just the
event title, date and times. This helps in limiting the
number of events and size of the calendar, since my work calendar
was taking up 1200K out of the available 2000K.
Events In Incorrect Timezone
Issues Resolved
 ===========================================

Within an hour the developer had responded to the issues, not only
acknowledging them but fixing them along with some requests for
more information about a segfault that happened after the sync.

After doing a git pull and re-building the source with the fixes,
my calendar sync'd over with all the right timezones and a much
smaller footprint since I limited the days to 30 and didn't include
notes.
Out and About
 ===========================================

With a fully working calendar and plenty of space on the Zire, it
was now time to take it out to use in the real world. I had some
errands to run in the morning, and used it to review my daily
agenda and todo list while at a local coffee shop.
Links
 ===========================================
Back