calcurse icon indicating copy to clipboard operation
calcurse copied to clipboard

Appointment as variable in notification

Open mb720 opened this issue 5 years ago • 5 comments

Hi!

I was wondering if it's possible to access the name of an appointment in the notification for it.

My goal is to notify myself of flagged appointments a couple of hours in advance per email. If the machine is not running at that exact moment, it should try again on the next occasion the machine is running.

I've got this in .config/calcurse/conf:

notification.command=echo "$(calcurse -n)" | mutt -s "Don't forget..." [email protected]

This works nicely if there's no unflagged appointment before the flagged one to which the notification belongs.

I think I could use a filter to with calcurse -n to get the next flagged appointment but this seems brittle, since if I change the notification.notifyall setting to get notified about all appointments, not only flagged once, the notification will refer to the wrong appointment.

I was wondering if there's a special variable like %m I could put into the notification.command that will get expanded to the appointment's title:

notification.command=echo "%m" | mutt -s "Don't forget..." [email protected]

mb720 avatar Apr 28 '20 08:04 mb720

I was wondering if it's possible to access the name of an appointment in the notification for it.

My goal is to notify myself of flagged appointments a couple of hours in advance per email.

I prefer to use the word "reminder", not "notification", see why https://github.com/lfos/calcurse/issues/285#issuecomment-620841221, but as explained you cannot achieve it in the way you describe.

I was wondering if there's a special variable like %m I could put into the notification.command that will get expanded to the appointment's title:

notification.command=echo "%m" | mutt -s "Don't forget..." [email protected]

There isn't such a format specifier, but I have felt the same need and have implemented %m together with %d and %t (guess what they expand to) in my private calcurse version. It wouldn't be difficult to port them to the public calcurse.

lhca avatar Apr 29 '20 13:04 lhca

Another thought: Can't we reuse the generic formatting utility functions that we already use for the --format-* command line options? We wouldn't be able to use all modifiers in a meaningful way (some only work for specific item types) but that would at least make many more modifiers available without introducing additional formatting code.

lfos avatar Apr 29 '20 13:04 lfos

That's an obvious first thought, but on closer look not so attractive. The print functions require knowledge of the appointment type (recurrent or not) besides access to the full appointment structure. But the notify threads work on a very stripped down appointment structure with only start time, state and message text copied from the original appointment structure.

lhca avatar Apr 29 '20 18:04 lhca

Hi, I just opened a pull request based on Ihca's notify-review branch from December 2018: https://github.com/lfos/calcurse/pull/466

I have tested this by editing the notification.command to use notify-send "%m" "%d" and it works nicely with swaync.

methuselah-0 avatar Aug 05 '23 20:08 methuselah-0