Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

reading from ical folders #1

Open
1 of 2 tasks
remowashere opened this issue Dec 26, 2023 · 3 comments
Open
1 of 2 tasks

reading from ical folders #1

remowashere opened this issue Dec 26, 2023 · 3 comments

Comments

@remowashere
Copy link

remowashere commented Dec 26, 2023

First of all; thanks for the awesome work! I've recently bought a Palm III and T|X and have been looking for a solid sync for weeks. This seems to work quite nice, but I do have a question;

My plan was to use vdirsyncer to fetch (and update!) my Baikal / iCloud calendars. All calendar items are stored as individual ics files and I guess that calendar-sync2 does the same after downloading/processing the ical/ics.

Would it be possible;

  • To specify a folder that contains all ics files and sync those to the Palm device?
  • First read the datebook and store new (added on Palm) records to the ics folder?

This way, you can add appointments on the device and sync them back to the cloud.

Thanks again!

@guruthree
Copy link
Owner

Thanks! I'm hoping that the code is helpful - or at least interesting to mess around with - for my fellow Palm enthusiasts.

The code uses a library (libical) that reads in ICS format data and then I take that and turn it straight into data for the Palm in memory using another library (libpisock) to handle transferring the data to the Palm so I'm not familiar with VCF files for calendar data. For the moment though I'll assume VCF is fully inter-compatible with ICS.

There's currently no way to read a directory of files, but you should be able to read in local files using file:https:///path/to/file.ics (like browsing local files in a web browser). If the number of files doesn't change you can create the config file to read in multiple files, but if the number is constantly changing then you can probably auto generate the config file using a shell script before syncing. Something like

cat cfg.header > temp.cfg
for l in icsfiles/*.ics;
do
    echo "\"file:https:///path/to/icsfiles/$l\"," >> temp.cfg
done
cat cfg.footer >> temp.cfg
apptainer run calendar-sync2.sif -c temp.cfg

where cfg.header is a file with everything before line 13 in the sample config file (up to and including URI=() and cfg.footer is everything line 15 to the end (from ) onwards).

There are config options to prevent overwriting the calendar on the palm pilot and to try updating events instead. These would be OVERWRITE=false and ONLYNEW=false

The pilot-link documentation suggests that getting calendar events back out of the palm can be done using the pilot-read-ical utility, but I've never used it before. It is included within the calendar-sync2.sif download via apptainer run --app pilot-read-ical calendar-sync2.sif if your distribution doesn't have pilot-link, but that is completely untested so your mileage may vary. You'll need to write your own scripts for merging that exported calendar back into your online calendar. I thought about this, but dealing with all the different protocols and APIs didn't seem worth it for my use case (which is to check upcoming events at a glance).

In general for the moment I'd be cautious about exporting anything imported using this repo back up to the cloud. Since I last updated anything I've noticed a couple times where events haven't synced to the palm correctly. Mostly long running repeating events that are changed don't seem to work properly and repeating events started in daylights savings time keep that time even in winter time. (Both on the to do list to try and fix, but unlikely to happen soon.)

@remowashere
Copy link
Author

remowashere commented Dec 27, 2023

That works as expected, 5k of .ics files are processed within a couple of seconds!

I just generate the full config with a bash script

#!/bin/bash

echo "URI=(" > custom.cfg

for i in ~/dav/calendars/icsdata/*.ics; do
    echo "\"file:https:///$i\"," >> custom.cfg
done

echo ")" >> custom.cfg

echo 'PORT="usb:"' >> custom.cfg
echo "DOHOTSYNC=true" >> custom.cfg
echo "READONLY=false" >> custom.cfg
echo "SECURE=true" >> custom.cfg
echo 'TIMEZONE="Europe/Amsterdam"' >> custom.cfg
echo "FROMYEAR=2023" >> custom.cfg
echo "OVERWRITE=true" >> custom.cfg
echo "ONLYNEW=false" >> custom.cfg
echo "DOALARMS=false" >> custom.cfg

apptainer run calendar-sync2.sif -c custom.cfg

Still have some timezone issues but I suspect it to be a Palm setting as the (config) timezone is shown during the sync process.

pilot-read-cal does bring up a new issue;

apptainer run --app pilot-read-ical calendar-sync2.sif -p usb: -f out.ics
Listening for incoming connection on usb:... connected!
sh: line 1: ical: command not found

As i'm on a Ubuntu (PopOS!) machine, I can't compile locally and I guess the Apptainer image is missing a PATH variable or something?

@remowashere remowashere changed the title local caldav folders reading from ical folders Dec 27, 2023
@guruthree
Copy link
Owner

Great that the sync to the Palm is working quickly! I'm not too surprised there are time zone issues and I wouldn't discount calendar-sync2 yet, as that ties in with there being daylight savings time changes issues as Google does DST changes as time zone changes. I've made a note it's likely a more general time zone issue on my to do list. (So it's not a surprise come spring time, I think calendar-sync2 assumes the Palm does not have DST enabled.)

The pilot-read-ical issue you're seeing explains the comment in the help Requires the program 'ical'. I've unfortunately been unable to figure out exactly which ical program it's expecting. Looking at https://github.com/desrod/pilot-link/blob/14338868111ce592c7ca7918a1f8a32ceecb7caf/src/pilot-read-ical.c#L151 it looks like the tool is trying to open a pipe to the ical binary where it then sends it the calendar events in a text readable format.

In lieu of finding the correct ical program I see a couple options, all requiring a bit of effort.

Option one would be to edit the apptainer image creation script to add a /usr/bin/ical file containing:

#!/bin/bash
cat - >> $5

with permissions +x which would dump things out into a text file that you would need to parse from scratch, rather than an already parsable ics file.

Option two would be quite invasive, but in short would be to clone the pilot-link repo, edit the pilot-read-ical.c to spit out a data format of your liking, clone the AUR package pilot-link repo to point to the cloned pilot-link repo, checkout this repo and edit the apptainer creation script to point to all the cloned repos and rebuild. Benefit here would be getting exactly the format you like. Taken to to the extreme this would be essentially writing the other half of calendar-sync2.

Option three would be to abandon pilot-read-ical and try to compile pilot-datebook, which according to the documentation should take a DatebookDB.pdb file and convert it to a CSV file. This would require either extracting libpisock and its header files from the apptainer image and compiling locally or editing the apptainer creation script to build it as well.

All of the apptainer-related hackery can be made easier to fiddle around with by using some commands like

apptainer build --sandbox calendar-sync2/ calendar-sync2.def
apptainer shell --fakeroot -c --writable calendar-sync2

which will put you inside the apptainer image after everything is done. Copy-pasting bits of the %post section of the .def file along with commenting bits out can put you at varying stages along in the build process to extract/modify things. (This is how I developed the image in the first place.)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants