jbalcorn / ical2rem

The original iCal to Remind script, first released in 2005 or so?
MIT License
24 stars 6 forks source link

"SCHED _sfun" in ical2rem.pl causes warnings in Remind 5.0.4 #8

Closed mlmatlock closed 2 months ago

mlmatlock commented 2 months ago

Downloading and converting my G-Cal, I get this:

REM Sep 5 2024 +3 AT 09:00 SCHED _sfun DURATION 1:00 MSG %a %2 %"Audiologist%"%

When starting remind/Tkremind, I get this:

/home/xxxxx/.config/remind/gcal_full.rem(5): Undefined SCHED function: `_sfun'

Still prints ok (for now).

jbalcorn commented 2 months ago

Ha! Amazing nobody has ever run into this before, since that's been in there since 0.2. Thanks for the report.

I'm open to suggestions. Dianne fixed in the distributed version by hardcoding +15

dfskoll commented 2 months ago

Hi, Justin et al...

I think hard-coding 15 is not ideal. If ical has a way to represent an advance warning timeout, we should probably take it from the ical input. Otherwise, perhaps a command-line option to add either "+n" or "SCHED _sfun" could be used? Something like:

--advance-warning=15 or --sched-fun=_sfun

when you invoke ical2rem.pl.

jbalcorn commented 2 months ago

Since a calendar entry can have multiple notifications, it's handled with a VALARM subentry

BEGIN:VALARM ACTION:DISPLAY TRIGGER:-P0DT1H0M0S DESCRIPTION:This is an event reminder END:VALARM

But that really isn't an idea supported by remind, since to have multiple notifications, you have to have a sched function. I do notice that while there is a warning, at least it does have a decent fail mode:

"If an error occurs during the evaluation of sched_func, then Remind reverts to using the AT time and the delta and repeat values, and never calls sched_func again."

So I can really see a few ways to handle.

1 - Dump the use of the SCHED function for calendar entries. We can't replicate what is put in the calendar anyway, and if you've got it in a calendar, you're probably being notified, this is just for info

2 - Use the sched-fun parameter. This would allow people to go ahead and define a sched function if they way to get notifications from remind. However, this would ignore the calendar entry configuration.

3 - If there's one or more VALARM entries, write out a SCHED -xx (or whatever) to match the first notification in the calendar entry, otherwise no SCHED entry. At least the first notification will match what's in the calendar.

I'm kinda leaning toward #1. That's definitely easiest :-)

other options?

dfskoll commented 2 months ago

I admit that I'm not familiar with ical, but isn't the usual case that a reminder has a single advance warning? I know when I add something on my phone, by default it warns me 30 minutes in advance and I just accept that.

So if there's only one VALARM, can't we just add a "+N" corresponding to the amount of warning it requests? And if there's more than one VALARM, just pick the earliest and don't worry about the rest? EDIT: that was basically your #3.

mlmatlock commented 2 months ago

I would lean to #1 as well. I really depend more on my phone/iPad notifications, especially if I'm not at my computer for a trigger time.

dfskoll commented 2 months ago

Oh hey, another thing you could do is have ical2rem.pl emit a header something like this:

IF args("_sfun") < 1
    FSET _sfun(x) choose(x, -60, 30, 5, 0)
ENDIF

which would use your definition of _sfun unless the user had already defined their own version.

jbalcorn commented 2 months ago

Oh that's a great idea. I'll take door Number 4 :-)

jbalcorn commented 2 months ago

I'm just using

IF args("_sfun") < 1
    FSET _func(x) choose(x,0)
ENDIF

so if no functions is defined, no reminders are set.

mlmatlock commented 2 months ago

@jbalcorn, thank you!!!