Appointments in org mode for today and for tomorrow as notifications

Keywords: org capture notifications

I use org mode to store appointments and I have configured Emacs to emit two reminders: one 15 minutes before the appointment and another one just before the appointment. The template I am using in org-capture for appointments (cita is appointment in Spanish) is:

 * CITA %^{Cita}
:LOOGBOOK:
Created: %U
:END:
%^T
%?

With this configuration for org-capture:

;; I assume that GTD_HOME holds the path of the agenda files
(setq citas (concat GTD_HOME "/citas.org")
(setq appts_tmpl (concat GTD_HOME "/templates/appts.org"))

(setq org-capture-templates
      (quote (
         ("c" "Cita" entry (file+headline citas "Citas") (file appts_tmpl) :prepend t)
         ;; Other entries
)))

This works pretty well, but I wanted the appointments for today and for tomorrow to appear as notifications when I start the laptop in order to have a clear view of them.

This is the script that parses the org file with the appointments, obtains those that are scheduled for today and for tomorrow and creates two notifications with notify-send.

#!/bin/bash
# Put here the full path to the file that you use for appointments
apptFile=${GTD_HOME}/citas.org
# Put here the keyword that you use for appointments in the file (for instace APPT)
apptKeywork=CITA

apptToday=$(cat "$appoinmentsFile"  | egrep "**${apptKeyword}|<[0-9]{4}" | grep -B1 $(date +%Y-%m-%d) | sed -e 's/>$/>\n/g' )
notify-send -u critical "Appointments for today" "$apptToday"

tomorrow=$(date --date="next day" +%Y-%m-%d)
apptTomorrow=$(cat "$appointmentsFile"  | egrep "**${apptKeyword}|<[0-9]{4}" | grep -B1 "$tomorrow" | sed -e 's/>$/>\n/g' )
notify-send -u critical "Appointments for tomorrow" "$apptTomorrow"

Finally, I have added that script to be executed at startup (on login). This is an example:

avisos-citas.png

Goto index

Date: 26/11/2020

Author: Juan GutiƩrrez Aguado

Emacs 27.1 (Org mode 9.4.4)

Validate