pmli...@free.fr (Peter Münster) writes: Hi Peter,
> I would like to be notified[1], when a todo item enters the warning > period, scheduled time, or deadline. I export my org entries as appt alarms, so that I get system notifications 15 minutes before meetings (every 1 minute until I discard them). Here's the code: --8<---------------cut here---------------start------------->8--- (defvar th-notify-title-to-id-map (make-hash-table :test 'string=) "Maps TITLE values of notifications to the last notification ID. If ID is -1, then any further notifications with that body will be skipped.") (defun th-notify (&rest args) "Create a notification popup. For ARGS, see `notifications-notify'. There's some new default behavior over the function above: - Notifications with same :body replace each other. :body, because my notifications are usually something like :title \"Meeting with Hugo\" :body \"In 15 Minutes\" where each minute a similar notification with decreasing minutes in the :body is triggered. - If a notification was dismissed, then don't show any notifications with that :title anymore (the next 15 minutes). - Use unlimited timeout." (require 'notifications) (let* ((title (plist-get args :body)) (body (plist-get args :body)) (replaces-id (or (plist-get args :replaces-id) (gethash title th-notify-title-to-id-map))) (on-close (or (plist-get args :on-close) `(lambda (id reason) (when (eq reason 'dismissed) ;; Mark as "don't show again!" (puthash ,title -1 th-notify-title-to-id-map) ;; But clear that "dont-show-mark" after 15 minutes (run-with-timer (* 15 60) nil (lambda () (remhash ,title th-notify-title-to-id-map))))))) ;; 0 means, it should not expire at all (timeout (or (plist-get args :timeout) 0))) (unless (eql replaces-id -1) (puthash title (apply 'notifications-notify (th-plist-put-many args :timeout timeout :replaces-id replaces-id :on-close on-close)) th-notify-title-to-id-map)))) (defun th-appt-alarm (mins time text) "Show a notification popup (or update the current one) for the appt with TEXT in MINS minutes (a string)." (let ((body (substring-no-properties text))) (th-notify :title text :body (concat "Appointment " (if (string= mins "0") "NOW:" (concat "in " mins " minutes:")))))) (setq appt-display-format 'window appt-disp-window-function 'th-appt-alarm appt-display-interval 1 appt-display-duration 60) (defun th-org-agenda-to-appt () (require 'org-agenda) (org-agenda-to-appt t) (appt-activate 1)) (th-org-agenda-to-appt) (add-hook 'org-finalize-agenda-hook 'th-org-agenda-to-appt) --8<---------------cut here---------------end--------------->8--- Bye, Tassilo